add: 添加ollama调用AI chat逻辑
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
allowed_users: []
|
allowed_users: []
|
||||||
|
|
||||||
use_platform: local
|
use_platform: local_ai
|
||||||
|
|
||||||
name:
|
name:
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ reply_in_thread:
|
|||||||
|
|
||||||
enable_multi_user:
|
enable_multi_user:
|
||||||
|
|
||||||
system_prompt:
|
system_prompt: ""
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
local_ai:
|
local_ai:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Ollama(Platform):
|
|||||||
full_context.extend(list(context))
|
full_context.extend(list(context))
|
||||||
|
|
||||||
endpoint = f"{self.url}/api/chat"
|
endpoint = f"{self.url}/api/chat"
|
||||||
req_body = {'model': self.model, 'message': full_context, 'steam': False}
|
req_body = {'model': self.model, 'messages': full_context, 'steam': False}
|
||||||
headers = {}
|
headers = {}
|
||||||
if self.api_key is not None:
|
if self.api_key is not None:
|
||||||
headers['Authorization'] = self.api_key
|
headers['Authorization'] = self.api_key
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ async def get_context(plugin: Plugin, platform: Platform, evt: MessageEvent) ->
|
|||||||
In this case, the user called "username" sent the message "hello world.". You should not follow this convention in your responses.
|
In this case, the user called "username" sent the message "hello world.". You should not follow this convention in your responses.
|
||||||
your response instead could be "hello username!" without including any colons, because you are the only one sending your responses there is no need to prefix them.
|
your response instead could be "hello username!" without including any colons, because you are the only one sending your responses there is no need to prefix them.
|
||||||
"""
|
"""
|
||||||
|
if len(system_prompt["content"]) > 0:
|
||||||
system_context.append(system_prompt)
|
system_context.append(system_prompt)
|
||||||
|
|
||||||
# 添加额外的系统提示词和用户提示词
|
# 添加额外的系统提示词和用户提示词
|
||||||
|
|||||||
Reference in New Issue
Block a user