Spaces:
Runtime error
Runtime error
Commit ·
b55f1be
1
Parent(s): 85e88d7
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,16 +5,21 @@ import os
|
|
| 5 |
|
| 6 |
def generate_plantuml_code(api_key, prompt):
|
| 7 |
openai.api_key = api_key
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
n=1,
|
| 13 |
stop=None,
|
| 14 |
temperature=0.7,
|
| 15 |
)
|
| 16 |
-
|
| 17 |
-
return
|
| 18 |
|
| 19 |
def plantuml_code_to_svg(plantuml_code):
|
| 20 |
with open("diagram.txt", "w") as f:
|
|
|
|
| 5 |
|
| 6 |
def generate_plantuml_code(api_key, prompt):
|
| 7 |
openai.api_key = api_key
|
| 8 |
+
messages = [
|
| 9 |
+
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
| 10 |
+
{'role': 'user', 'content': prompt}
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
completions = openai.ChatCompletion.create(
|
| 14 |
+
model="gpt-3.5-turbo",
|
| 15 |
+
messages=messages,
|
| 16 |
+
max_tokens=512,
|
| 17 |
n=1,
|
| 18 |
stop=None,
|
| 19 |
temperature=0.7,
|
| 20 |
)
|
| 21 |
+
message = completions.choices[0].message['content']
|
| 22 |
+
return message
|
| 23 |
|
| 24 |
def plantuml_code_to_svg(plantuml_code):
|
| 25 |
with open("diagram.txt", "w") as f:
|