add: 添加ollama调用AI chat逻辑
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
from aiohttp import ClientSession
|
||||||
from mautrix.types import MessageEvent
|
from mautrix.types import MessageEvent
|
||||||
from mautrix.util.config import BaseProxyConfig
|
from mautrix.util.config import BaseProxyConfig
|
||||||
|
|
||||||
@@ -11,8 +12,8 @@ from maubot_llmplus.platforms import Platform, ChatCompletion
|
|||||||
class Ollama(Platform):
|
class Ollama(Platform):
|
||||||
chat_api: str
|
chat_api: str
|
||||||
|
|
||||||
def __init__(self, config: BaseProxyConfig) -> None:
|
def __init__(self, config: BaseProxyConfig, http: ClientSession) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config, http)
|
||||||
self.chat_api = '/api/chat'
|
self.chat_api = '/api/chat'
|
||||||
|
|
||||||
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from aiohttp import ClientSession
|
||||||
from mautrix.types import MessageEvent
|
from mautrix.types import MessageEvent
|
||||||
from mautrix.util.config import BaseProxyConfig
|
from mautrix.util.config import BaseProxyConfig
|
||||||
|
|
||||||
@@ -6,8 +7,8 @@ from maubot_llmplus.platforms import Platform, ChatCompletion
|
|||||||
|
|
||||||
class OpenAi(Platform):
|
class OpenAi(Platform):
|
||||||
|
|
||||||
def __init__(self, config: BaseProxyConfig) -> None:
|
def __init__(self, config: BaseProxyConfig, http: ClientSession) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config, http)
|
||||||
|
|
||||||
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
||||||
# 获取系统提示词
|
# 获取系统提示词
|
||||||
@@ -21,8 +22,8 @@ class OpenAi(Platform):
|
|||||||
|
|
||||||
class Anthropic(Platform):
|
class Anthropic(Platform):
|
||||||
|
|
||||||
def __init__(self, config: BaseProxyConfig) -> None:
|
def __init__(self, config: BaseProxyConfig, http: ClientSession) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config, http)
|
||||||
|
|
||||||
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
async def create_chat_completion(self, evt: MessageEvent) -> ChatCompletion:
|
||||||
# 获取系统提示词
|
# 获取系统提示词
|
||||||
|
|||||||
Reference in New Issue
Block a user