ollama llm(library) list 확인 : curl http://localhost:11434/api/tags
from agents import Agent, Runner
from dotenv import load_dotenv
load_dotenv()
def main():
agent = Agent(
name='Assistant',
instructions='You are a helpful assistant. Always maintain memory of the conversation history and remember the user\'s name is Dabid.',
model="gpt-4o-mini",
)
messages = []
while True:
user_input = input("\nYou: ")
messages.append({"role": "user", "content": user_input})
print("Assistant: ", end="")
result = Runner.run_sync(
agent,
input=messages
)
assistant_response = str(result.final_output)
print(assistant_response)
messages.append({"role": "assistant", "content": assistant_response})
# Run it
if __name__ == "__main__":
main()
import requests
from dotenv import load_dotenv
load_dotenv()
OLLAMA_URL = "http://localhost:11434/api/chat"
def main():
system_prompt = {
"role": "system",
"content": "You are a helpful assistant. Always maintain memory of the conversation history and remember the user's name is Dabid."
}
messages = [system_prompt]
while True:
user_input = input("\nYou: ")
messages.append({"role": "user", "content": user_input})
payload = {
"model": "qwen2.5:7b-instruct",
"messages": messages,
"stream": False
}
response = requests.post(OLLAMA_URL, json=payload)
response.raise_for_status()
assistant_response = response.json()["message"]["content"]
print("Assistant:", assistant_response)
messages.append({"role": "assistant", "content": assistant_response})
if __name__ == "__main__":
main()