sorta working now
Browse files- .gitignore +1 -1
- app.py +20 -5
.gitignore
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
.env
|
|
|
|
| 1 |
+
.env
|
app.py
CHANGED
|
@@ -3,22 +3,37 @@ import openai
|
|
| 3 |
import os
|
| 4 |
import random
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
#generates an AI description of your character
|
| 9 |
def describe(names,wis,char,str,int,dex,con):
|
| 10 |
print(f"hi{names}")
|
| 11 |
-
completion =
|
| 12 |
-
|
| 13 |
prompt=names,
|
| 14 |
-
max_tokens=
|
| 15 |
-
temperature=0.
|
| 16 |
frequency_penalty=0.2,
|
| 17 |
presence_penalty= 0.25)
|
| 18 |
|
| 19 |
result =completion.choices[0].text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if not result :
|
| 21 |
result = "Could you be any more boring?"
|
|
|
|
| 22 |
|
| 23 |
return result
|
| 24 |
|
|
|
|
| 3 |
import os
|
| 4 |
import random
|
| 5 |
|
| 6 |
+
from dotenv import load_dotenv
|
| 7 |
+
from openai import OpenAI
|
| 8 |
+
|
| 9 |
+
load_dotenv()
|
| 10 |
+
|
| 11 |
openai.api_key = os.getenv('OPENAI_API_KEY')
|
| 12 |
+
print(openai.api_key)
|
| 13 |
+
print (os.environ.get("OPENAI_API_KEY"))
|
| 14 |
+
client = openai.OpenAI(organization='org-eiNl8e4nk93VLQFDb4EBz9JG')
|
| 15 |
+
#openai.api_key = os.environ['openai'] #for huggingface i think
|
| 16 |
+
|
| 17 |
#generates an AI description of your character
|
| 18 |
def describe(names,wis,char,str,int,dex,con):
|
| 19 |
print(f"hi{names}")
|
| 20 |
+
completion = client.completions.create(
|
| 21 |
+
model='gpt-3.5-turbo-instruct',
|
| 22 |
prompt=names,
|
| 23 |
+
max_tokens=310,
|
| 24 |
+
temperature=0.77,
|
| 25 |
frequency_penalty=0.2,
|
| 26 |
presence_penalty= 0.25)
|
| 27 |
|
| 28 |
result =completion.choices[0].text
|
| 29 |
+
#print(dict(completion).get('usage'))
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
#print(completion.model_dump_json(indent=2))
|
| 33 |
+
|
| 34 |
if not result :
|
| 35 |
result = "Could you be any more boring?"
|
| 36 |
+
|
| 37 |
|
| 38 |
return result
|
| 39 |
|