From 22d646e8ae286e7a73ee8f20aca173dd5cbbe232 Mon Sep 17 00:00:00 2001 From: retoor <retoor@molodetz.nl> Date: Thu, 3 Apr 2025 12:51:22 +0200 Subject: [PATCH] Update. --- test_openai_api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test_openai_api.py diff --git a/test_openai_api.py b/test_openai_api.py new file mode 100644 index 0000000..be09f7e --- /dev/null +++ b/test_openai_api.py @@ -0,0 +1,17 @@ +from openai import OpenAI + +client = OpenAI( + base_url = 'https://ollama.molodetz.nl/v1', + api_key='ollama', # required, but unused +) + +response = client.chat.completions.create( + model="llama2", + messages=[ + {"role": "system", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Who won the world series in 2020?"}, + {"role": "assistant", "content": "The LA Dodgers won in 2020."}, + {"role": "user", "content": "Where was it played?"} + ] +) +print(response.choices[0].message.content)