Spaces:
Runtime error
Runtime error
Update ai_generate.py
Browse files- ai_generate.py +18 -0
ai_generate.py
CHANGED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import pandas as pd
|
3 |
+
import torch
|
4 |
+
import openai
|
5 |
+
|
6 |
+
model = "gpt-3.5-turbo"
|
7 |
+
openai.api_key = "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"
|
8 |
+
|
9 |
+
def generate(text):
|
10 |
+
message=[{"role": "user", "content": text}]
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model=model,
|
13 |
+
messages = message,
|
14 |
+
temperature=0.2,
|
15 |
+
max_tokens=800,
|
16 |
+
frequency_penalty=0.0
|
17 |
+
)
|
18 |
+
return response
|