Skip to content

Commit

Permalink
Merge pull request #14 from ctavolazzi/NovaGPT
Browse files Browse the repository at this point in the history
Clean branch for NovaGPT
  • Loading branch information
ctavolazzi authored Nov 14, 2023
2 parents 9a37422 + f1a0eac commit ce2c4bc
Show file tree
Hide file tree
Showing 86 changed files with 403 additions and 157 deletions.
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

153 changes: 0 additions & 153 deletions .gitignore

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
90 changes: 90 additions & 0 deletions Archive/NovaSystem_v0.0.1/NovaHelper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import time
<<<<<<< HEAD
import logging
import openai
import os
from dotenv import load_dotenv

# Load environment variables from the .env file
load_dotenv()

# Retrieve and debug the OpenAI API key from environment variables
os.getenv("OPENAI_API_KEY")

# Validate that the API key exists
if os.getenv("OPENAI_API_KEY") is None:
raise ValueError("API key not found in environment variables.")

# # Define the prompt and model
# prompt = "Translate the following English text to French: '{}'"
# text = "Hello, world"
# model = "gpt-3.5-turbo" # Replace with actual GPT-4 identifier when available

=======
>>>>>>> b6f8c82 (🪄 📌 🔎x)

class NovaHelper():
_default_delay = 0.022

def __init__(self):
self.classification = 'NovaHelper'

def test(self):
self.stc(f'Testing NovaHelper...\n')
self.stc(f'classification: {self.classification}\n')
self.stc(f'{self.classification} class instantiated successfully.')

def stream_to_console(self, message, delay=_default_delay):
for char in message:
print(char, end='', flush=True)
time.sleep(delay)

def stc(self, message, delay=_default_delay):
self.stream_to_console(message, delay)

<<<<<<< HEAD
def fetch_response_from_default_API(self, request={'API': 'openai', 'request': {'prompt': 'Hello, world', 'model': 'gpt-3.5-turbo', 'max_tokens': 60}}):
# Unpack request
print(f'Helper Calling API...\n')
for k, v in request.items():
print(f'{k}: {v}')
# Make API call and return response
pass

def make_api_call(self, callback=None):
# Make API call and return response
print(type(callback))
if type(callback) is str:
# Make API to OpenAI and return resopnse
# response = openai.Completion.create(
# model = 'gpt-3.5-turbo',
# prompt='This is a test',
# max_tokens=5,
# api_key=os.getenv("OPENAI_API_KEY")
# )

openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(
model="gpt-3.5-turbo-instruct-0914",
prompt=callback,
max_tokens=50,
temperature=.5
)

return response

if callback is not None:
callback()
else:
self.fetch_response_from_default_API()
pass

=======
>>>>>>> b6f8c82 (🪄 📌 🔎x)
def stc(message, delay=0.022):
helper = NovaHelper()
helper.stream_to_console(message, delay)

if __name__ == "__main__":
helper = NovaHelper()
helper.test()
Loading

0 comments on commit ce2c4bc

Please sign in to comment.