Added better instructions
This commit is contained in:
@@ -14,7 +14,7 @@ class StandaloneLLMTool(BaseTool):
|
||||
logging.warning("COPILOT_API_URL environment variable not set. call_external_copilot will not function.")
|
||||
|
||||
def clear(self):
|
||||
pass
|
||||
self._call_external_copilot("/clear")
|
||||
|
||||
def get_functions(self):
|
||||
return [
|
||||
@@ -51,7 +51,7 @@ class StandaloneLLMTool(BaseTool):
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "call_external_copilot",
|
||||
"description": "Calls a separate AI copilot instance over HTTP to get a response.",
|
||||
"description": "Chat with an AI copilot instance.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -73,17 +73,15 @@ class StandaloneLLMTool(BaseTool):
|
||||
|
||||
logging.info(f"Calling external copilot at URL: {self.copilot_url} with prompt: {prompt[:50]}...")
|
||||
if not self.copilot_url.startswith('http://') and not self.copilot_url.startswith('https://'):
|
||||
error_message = f"Invalid URL scheme for external copilot: {self.copilot_url}. URL must start with http:// or https://"
|
||||
logging.error(error_message)
|
||||
return error_message
|
||||
self.copilot_url = 'http://' + self.copilot_url
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
self.copilot_url,
|
||||
self.copilot_url + "/copilot",
|
||||
data=prompt.encode('utf-8'),
|
||||
headers={'Content-Type': 'text/plain; charset=utf-8', 'User-Agent': 'DualAICopilot/0.1'},
|
||||
method='POST'
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=60) as response:
|
||||
with urllib.request.urlopen(req, timeout=500) as response:
|
||||
if response.status == 200:
|
||||
response_data = response.read().decode('utf-8')
|
||||
logging.info(f"Received response from external copilot: {response_data[:100]}...")
|
||||
|
||||
Reference in New Issue
Block a user