# The WeatherAPI class is a Pydantic BaseModel that represents the data structure
# for making API calls to retrieve weather information. It has two attributes: city and date.
# Example usage:
# Initialize the function caller
model=OpenAIFunctionCaller(
system_prompt="You're the code interpreter agent, your purpose is to generate code given a task and provide a summary, pseudocode, and code for the algorithm.",
max_tokens=3400,
temperature=0.5,
base_model=CodeSpec,
parallel_tool_calls=False,
)
defrun_model_and_generate_code(max_loops:int=2):
question="What is the task for the code interpreter agent?"
task=input(question)
responses=[]
responses.append(question)
responses.append(task)
foriinrange(max_loops):
task=concat_strings(task)
out=model.run(task)
summary=out["summary"]
print("\nSummary: ",summary)
pseudocode=out["algorithmic_pseudocode"]
code=clean_model_code(out["code"])
output=f"{summary}\n\n{pseudocode}\n\n{code}"
responses.append(output)
# Code Executor
executor=CodeExecutor()
# Execute the code
result=executor.execute(code)
if"error"inresult:
print(f"Error: {result}")
break
print("\nCode Output: ",result)
task=input(
"\nEnter the next task for the code interpreter agent (or 'exit' to stop): "