Spaces:
Sleeping
Sleeping
Fixed openai api key import
Browse files- README.md +11 -0
- app.py +1 -0
- cbr_athena/Gradio_Test.py +1 -1
- cbr_athena/api/Chat_Predict.py +3 -4
- cbr_athena/api/Open_API.py +2 -2
- tests/test_Gradio_Test.py +4 -0
README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: CBR Athena
|
3 |
+
emoji: 👀
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.40.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
app.py
CHANGED
@@ -3,6 +3,7 @@ from dotenv import load_dotenv
|
|
3 |
from cbr_athena.Gradio_Test import Gradio_Test
|
4 |
|
5 |
load_dotenv()
|
|
|
6 |
gradio_test = Gradio_Test()
|
7 |
demo = gradio_test.create_demo()
|
8 |
|
|
|
3 |
from cbr_athena.Gradio_Test import Gradio_Test
|
4 |
|
5 |
load_dotenv()
|
6 |
+
|
7 |
gradio_test = Gradio_Test()
|
8 |
demo = gradio_test.create_demo()
|
9 |
|
cbr_athena/Gradio_Test.py
CHANGED
@@ -6,7 +6,7 @@ from osbot_utils.utils.Misc import list_set
|
|
6 |
from cbr_athena.api.Chat_Predict import Chat_Predict
|
7 |
from cbr_athena.api.Open_API import Open_API
|
8 |
|
9 |
-
|
10 |
|
11 |
|
12 |
TITLE = "# Meet Bobby Tables (head of Application Security). v0.2.0"
|
|
|
6 |
from cbr_athena.api.Chat_Predict import Chat_Predict
|
7 |
from cbr_athena.api.Open_API import Open_API
|
8 |
|
9 |
+
|
10 |
|
11 |
|
12 |
TITLE = "# Meet Bobby Tables (head of Application Security). v0.2.0"
|
cbr_athena/api/Chat_Predict.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
import openai
|
2 |
from osbot_utils.utils.Dev import pprint
|
3 |
|
|
|
|
|
4 |
|
5 |
class Chat_Predict:
|
6 |
|
7 |
def __init__(self):
|
8 |
self.last_message = None
|
9 |
self.last_response = None
|
|
|
10 |
|
11 |
def default_prompt(self):
|
12 |
system_prompt = """
|
@@ -37,10 +40,6 @@ Project that the viewer might be interested in.
|
|
37 |
return {"role": "system", "content": system_prompt}
|
38 |
|
39 |
def predict(self, message, history):
|
40 |
-
# print('--'*50)
|
41 |
-
# print("Message:", message)
|
42 |
-
# print("History:", history)
|
43 |
-
# print('--' * 50)
|
44 |
history_openai_format = []
|
45 |
history_openai_format.append(self.default_prompt())
|
46 |
for human, assistant in history:
|
|
|
1 |
import openai
|
2 |
from osbot_utils.utils.Dev import pprint
|
3 |
|
4 |
+
from cbr_athena.api.Open_API import Open_API
|
5 |
+
|
6 |
|
7 |
class Chat_Predict:
|
8 |
|
9 |
def __init__(self):
|
10 |
self.last_message = None
|
11 |
self.last_response = None
|
12 |
+
Open_API().setup()
|
13 |
|
14 |
def default_prompt(self):
|
15 |
system_prompt = """
|
|
|
40 |
return {"role": "system", "content": system_prompt}
|
41 |
|
42 |
def predict(self, message, history):
|
|
|
|
|
|
|
|
|
43 |
history_openai_format = []
|
44 |
history_openai_format.append(self.default_prompt())
|
45 |
for human, assistant in history:
|
cbr_athena/api/Open_API.py
CHANGED
@@ -5,7 +5,7 @@ from dotenv import load_dotenv
|
|
5 |
from openai import ChatCompletion
|
6 |
from osbot_utils.decorators.methods.cache_on_self import cache_on_self
|
7 |
|
8 |
-
|
9 |
|
10 |
class Open_API:
|
11 |
|
@@ -15,7 +15,7 @@ class Open_API:
|
|
15 |
@cache_on_self
|
16 |
def api_key(self):
|
17 |
load_dotenv()
|
18 |
-
return getenv(
|
19 |
|
20 |
def create(self):
|
21 |
history_openai_format = self.messages()
|
|
|
5 |
from openai import ChatCompletion
|
6 |
from osbot_utils.decorators.methods.cache_on_self import cache_on_self
|
7 |
|
8 |
+
OPEN_AI__API_KEY = 'OPEN_AI__API_KEY'
|
9 |
|
10 |
class Open_API:
|
11 |
|
|
|
15 |
@cache_on_self
|
16 |
def api_key(self):
|
17 |
load_dotenv()
|
18 |
+
return getenv(OPEN_AI__API_KEY)
|
19 |
|
20 |
def create(self):
|
21 |
history_openai_format = self.messages()
|
tests/test_Gradio_Test.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
class test_Gradio_Test(TestCase):
|
2 |
+
|
3 |
+
def setUp(self):
|
4 |
+
open_api = Open_API()
|