mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
Adds AI functions.
These are no-code functions written by AI.
This commit is contained in:
16
scripts/ai_functions.py
Normal file
16
scripts/ai_functions.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import List, Optional
|
||||
import json
|
||||
import openai
|
||||
|
||||
def call_ai_function(function, args, description, model = "gpt-4"):
|
||||
# parse args to comma seperated string
|
||||
args = ", ".join(args)
|
||||
messages = [{"role": "system", "content": f"You are now the following python function: ```# {description}\n{function}```\n\nOnly respond with your `return` value."},{"role": "user", "content": args}]
|
||||
|
||||
response = openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=0
|
||||
)
|
||||
|
||||
return response.choices[0].message["content"]
|
||||
Reference in New Issue
Block a user