Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model to status info issue #3 #17

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
36 changes: 36 additions & 0 deletions easycompletion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def function_completion(
api_key=None,
debug=DEBUG,
temperature=0.0,

):
"""
Send text and a list of functions to the model and return optional text and a function call.
Expand Down Expand Up @@ -574,5 +575,40 @@ def function_completion(
"arguments": arguments,
"usage": usage,
"finish_reason": finish_reason,
"model_used": model, # Include the model used in the response
"error": None,
}


def status_info(api_key=None, model=None, debug=DEBUG):
"""
Get status information about the API key and model.

Parameters:
api_key (str, optional): OpenAI API key. If not provided, it uses the one defined in constants.py.
model (str, optional): The model to use. Default is the TEXT_MODEL defined in constants.py.

Returns:
dict: A dictionary containing status information.

Example:
>>> status_info(api_key='your_openai_api_key', model='gpt-3.5-turbo')
"""
# Validate the API key
if not validate_api_key(api_key):
return {"error": "Invalid OpenAI API key"}

openai.api_key = api_key

if model is None:
model = TEXT_MODEL

# Get the model information
model_info = openai.Model.retrieve(model)
model_status = model_info.status

return {
"api_key": api_key,
"model": model,
"model_status": model_status,
}
226 changes: 0 additions & 226 deletions easycompletion/prompt.py

This file was deleted.

5 changes: 5 additions & 0 deletions easycompletion/tests/model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import openai
from easycompletion.model import (
chat_completion,
parse_arguments,
function_completion,
text_completion,
)

# Check if the OpenAI API key is set
if not openai.api_key:
raise ValueError("OpenAI API key is missing. Set your API key using 'openai.api_key = <YOUR_API_KEY>'.")


def test_parse_arguments():
test_input = '{"key1": "value1", "key2": 2}'
Expand Down
69 changes: 0 additions & 69 deletions easycompletion/tests/prompt.py

This file was deleted.