Spaces:
Sleeping
Sleeping
File size: 791 Bytes
d4fb7ee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import openai
import json
from typing import List, Dict
import os
# Set your OpenAI API key in an environment variable
# This small function is set separately as in an enterprise, invoking api might not be as straightforward.
# This would abstract the underlying hops/complexities if we want to make an LLM call.
openai.api_key = os.environ.get('api_key')
def invoke_api(system_prompt,user_message,temp,max_tokens=50):
response = openai.ChatCompletion.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_message}
],
temperature=temp,
max_tokens =max_tokens
)
return response
|