first commit
This commit is contained in:
35
app.py
35
app.py
@@ -1,12 +1,41 @@
|
||||
import openai
|
||||
from flask import Flask
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
load_dotenv()
|
||||
openai.api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
@app.route('/')
|
||||
def hello_world(): # put application's code here
|
||||
return 'Hello World!'
|
||||
|
||||
def generate_summarizer(
|
||||
max_tokens,
|
||||
temperature,
|
||||
top_p,
|
||||
frequency_penalty,
|
||||
prompt,
|
||||
person_type,
|
||||
):
|
||||
res = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
max_tokens=100,
|
||||
temperature=0.7,
|
||||
top_p=0.5,
|
||||
frequency_penalty=0.5,
|
||||
messages=
|
||||
[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant for text summarization.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Summarize this for a {person_type}: {prompt}",
|
||||
},
|
||||
],
|
||||
)
|
||||
return res["choices"][0]["message"]["content"]
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
||||
Reference in New Issue
Block a user