readme update & refactor llm_provider
This commit is contained in:
@@ -552,8 +552,8 @@ We’re looking for developers to improve AgenticSeek! Check out open issues or
|
||||
|
||||
## Maintainers:
|
||||
|
||||
> [Fosowl](https://github.com/Fosowl) | Paris Time | (Sometime busy)
|
||||
> [Fosowl](https://github.com/Fosowl) | Paris Time
|
||||
|
||||
> [https://github.com/antoineVIVIES](antoineVIVIES) | Taipei Time | (Often busy)
|
||||
> [antoineVIVIES](https://github.com/antoineVIVIES) | Taipei Time
|
||||
|
||||
> [steveh8758](https://github.com/steveh8758) | Taipei Time | (Always busy)
|
||||
> [steveh8758](https://github.com/steveh8758) | Taipei Time
|
||||
+3
-3
@@ -564,8 +564,8 @@ DeepSeek R1 天生会说中文
|
||||
|
||||
## 维护者:
|
||||
|
||||
> [Fosowl](https://github.com/Fosowl) | 巴黎时间 | (有时很忙)
|
||||
> [Fosowl](https://github.com/Fosowl) | 巴黎时间
|
||||
|
||||
> [https://github.com/antoineVIVIES](https://github.com/antoineVIVIES) | 台北时间 | (经常很忙)
|
||||
> [antoineVIVIES](https://github.com/antoineVIVIES) | Taipei Time
|
||||
|
||||
> [steveh8758](https://github.com/steveh8758) | 台北时间 | (总是很忙)
|
||||
> [steveh8758](https://github.com/steveh8758) | 台北时间
|
||||
|
||||
+3
-3
@@ -556,8 +556,8 @@ DeepSeek R1 天生会说中文
|
||||
|
||||
## 维护者:
|
||||
|
||||
> [Fosowl](https://github.com/Fosowl) | 巴黎时间 | (有时很忙)
|
||||
> [Fosowl](https://github.com/Fosowl) | 巴黎时间
|
||||
|
||||
> [https://github.com/antoineVIVIES](https://github.com/antoineVIVIES) | 台北时间 | (经常很忙)
|
||||
> [antoineVIVIES](https://github.com/antoineVIVIES) | Taipei Time
|
||||
|
||||
> [steveh8758](https://github.com/steveh8758) | 台北时间 | (总是很忙)
|
||||
> [steveh8758](https://github.com/steveh8758) | 台北时间
|
||||
+1
-1
@@ -495,4 +495,4 @@ Nous recherchons des développeurs pour améliorer AgenticSeek ! Consultez la se
|
||||
## Mainteneurs:
|
||||
> [Fosowl](https://github.com/Fosowl)
|
||||
> [steveh8758](https://github.com/steveh8758)
|
||||
> [https://github.com/antoineVIVIES](https://github.com/antoineVIVIES)
|
||||
> [antoineVIVIES](https://github.com/antoineVIVIES) | Taipei Time
|
||||
|
||||
+1
-1
@@ -565,6 +565,6 @@ AgenticSeekを改善するための開発者を募集しています!オープ
|
||||
|
||||
> [Fosowl](https://github.com/Fosowl) | パリ時間
|
||||
|
||||
> [https://github.com/antoineVIVIES](antoineVIVIES) | 台北時間
|
||||
> [antoineVIVIES](https://github.com/antoineVIVIES) | Taipei Time
|
||||
|
||||
> [steveh8758](https://github.com/steveh8758) | 台北時間 |(常に忙しい)
|
||||
+32
-33
@@ -14,7 +14,6 @@ from openai import OpenAI
|
||||
from sources.logger import Logger
|
||||
from sources.utility import pretty_print, animate_thinking
|
||||
|
||||
|
||||
class Provider:
|
||||
def __init__(self, provider_name, model, server_address="127.0.0.1:5000", is_local=False):
|
||||
self.provider_name = provider_name.lower()
|
||||
@@ -58,38 +57,6 @@ class Provider:
|
||||
exit(1)
|
||||
return api_key
|
||||
|
||||
def anthropic_fn(self, history, verbose=False):
|
||||
"""
|
||||
Use Anthropic to generate text.
|
||||
"""
|
||||
from anthropic import Anthropic
|
||||
|
||||
client = Anthropic(api_key=self.api_key)
|
||||
system_message = None
|
||||
messages = []
|
||||
for message in history:
|
||||
clean_message = {'role': message['role'], 'content': message['content']}
|
||||
if message['role'] == 'system':
|
||||
system_message = message['content']
|
||||
else:
|
||||
messages.append(clean_message)
|
||||
|
||||
try:
|
||||
response = client.messages.create(
|
||||
model=self.model,
|
||||
max_tokens=1024,
|
||||
messages=messages,
|
||||
system=system_message
|
||||
)
|
||||
if response is None:
|
||||
raise Exception("Anthropic response is empty.")
|
||||
thought = response.content[0].text
|
||||
if verbose:
|
||||
print(thought)
|
||||
return thought
|
||||
except Exception as e:
|
||||
raise Exception(f"Anthropic API error: {str(e)}") from e
|
||||
|
||||
def respond(self, history, verbose=True):
|
||||
"""
|
||||
Use the choosen provider to generate text.
|
||||
@@ -255,6 +222,38 @@ class Provider:
|
||||
except Exception as e:
|
||||
raise Exception(f"OpenAI API error: {str(e)}") from e
|
||||
|
||||
def anthropic_fn(self, history, verbose=False):
|
||||
"""
|
||||
Use Anthropic to generate text.
|
||||
"""
|
||||
from anthropic import Anthropic
|
||||
|
||||
client = Anthropic(api_key=self.api_key)
|
||||
system_message = None
|
||||
messages = []
|
||||
for message in history:
|
||||
clean_message = {'role': message['role'], 'content': message['content']}
|
||||
if message['role'] == 'system':
|
||||
system_message = message['content']
|
||||
else:
|
||||
messages.append(clean_message)
|
||||
|
||||
try:
|
||||
response = client.messages.create(
|
||||
model=self.model,
|
||||
max_tokens=1024,
|
||||
messages=messages,
|
||||
system=system_message
|
||||
)
|
||||
if response is None:
|
||||
raise Exception("Anthropic response is empty.")
|
||||
thought = response.content[0].text
|
||||
if verbose:
|
||||
print(thought)
|
||||
return thought
|
||||
except Exception as e:
|
||||
raise Exception(f"Anthropic API error: {str(e)}") from e
|
||||
|
||||
def google_fn(self, history, verbose=False):
|
||||
"""
|
||||
Use google gemini to generate text.
|
||||
|
||||
Reference in New Issue
Block a user