feat: merge geekan:main

This commit is contained in:
莘权 马 2023-12-22 16:40:04 +08:00
commit 9a1909bb95
139 changed files with 4649 additions and 1504 deletions

View file

@ -1,10 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/8/17
@Author : mashenquan
@Time : 2023/6/9 22:22
@Author : Leo Xiao
@File : azure_tts.py
@Desc : azure TTS OAS3 api, which provides text-to-speech functionality
@Modified by: mashenquan, 2023/8/17. Azure TTS OAS3 api, which provides text-to-speech functionality
"""
import asyncio
import base64

View file

@ -46,7 +46,6 @@ class OpenCodeInterpreter(object):
interpreter.auto_run = auto_run
interpreter.model = CONFIG.openai_api_model or "gpt-3.5-turbo"
interpreter.api_key = CONFIG.openai_api_key
# interpreter.api_base = CONFIG.openai_api_base
self.interpreter = interpreter
def chat(self, query: str, reset: bool = True):

View file

@ -5,6 +5,7 @@
@Author : zhanglei
@File : moderation.py
"""
import asyncio
from typing import Union
from metagpt.llm import LLM
@ -14,16 +15,6 @@ class Moderation:
def __init__(self):
self.llm = LLM()
def moderation(self, content: Union[str, list[str]]):
resp = []
if content:
moderation_results = self.llm.moderation(content=content)
results = moderation_results.results
for item in results:
resp.append(item.flagged)
return resp
async def amoderation(self, content: Union[str, list[str]]):
resp = []
if content:
@ -35,6 +26,13 @@ class Moderation:
return resp
if __name__ == "__main__":
async def main():
moderation = Moderation()
print(moderation.moderation(content=["I will kill you", "The weather is really nice today", "I want to hit you"]))
rsp = await moderation.amoderation(
content=["I will kill you", "The weather is really nice today", "I want to hit you"]
)
print(rsp)
if __name__ == "__main__":
asyncio.run(main())

View file

@ -111,6 +111,8 @@ def _gen_get_driver_func(browser_type, *args, executable_path=None):
options.add_argument("--headless")
options.add_argument("--enable-javascript")
if browser_type == "chrome":
options.add_argument("--disable-gpu") # This flag can help avoid renderer issue
options.add_argument("--disable-dev-shm-usage") # Overcome limited resource problems
options.add_argument("--no-sandbox")
for i in args:
options.add_argument(i)