Spaces:
Sleeping
Sleeping
| 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 | |