ver Jan31stv4
evaluating som on calc
This commit is contained in:
39
test_connection.py
Normal file
39
test_connection.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#import openai
|
||||
#import yaml
|
||||
#from typing import Dict
|
||||
import os
|
||||
import requests
|
||||
|
||||
# with open("openaiconfig.yaml") as f:
|
||||
# config: Dict[str, str] = yaml.load(f, Loader=yaml.Loader)
|
||||
# openai.api_key = config["api_key"]
|
||||
|
||||
#with open("llmcases/debug-20230420@191814.log.api_version.-1") as f:
|
||||
#prompt = f.read()
|
||||
#prompt = "Hello, "
|
||||
prompt = [ { "role": "user"
|
||||
, "content": "Hello,"
|
||||
}
|
||||
]
|
||||
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
payload = { "model": "gpt-4-vision-preview"
|
||||
, "messages": prompt
|
||||
, "max_tokens": 100
|
||||
}
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {api_key}"
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
"https://api.openai.com/v1/chat/completions",
|
||||
headers=headers,
|
||||
json=payload
|
||||
)
|
||||
|
||||
#completion = openai.Completion.create( model="gpt-4-vision-preview"
|
||||
#, prompt=prompt
|
||||
#, request_timeout=20.
|
||||
#)
|
||||
print(response.json())
|
||||
Reference in New Issue
Block a user