More refine
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/home/hollorol/miniconda3/envs/llm/bin/python
|
||||
|
||||
import subprocess as sp
|
||||
from openai import OpenAI
|
||||
import sys
|
||||
|
||||
API_KEY = sp.getoutput("pass show openai_apikey")
|
||||
client = OpenAI(api_key=API_KEY)
|
||||
temperature = 0.4
|
||||
|
||||
def generate(text_message):
|
||||
prompt = f"""
|
||||
You are an AI that generates text based on the prompt. You have to use the user provided text as a base, all text should be continiuos and coherent.
|
||||
"""
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="gpt-4o-mini",
|
||||
messages=[{"role": "system", "content": prompt},
|
||||
{"role": "user", "content": text_message}],
|
||||
temperature=temperature # Adjust for creativity
|
||||
)
|
||||
|
||||
response = response.choices[0].message.content
|
||||
print(response)
|
||||
|
||||
if __name__ == "__main__":
|
||||
text_message = sys.stdin.read().strip()
|
||||
generate(text_message)
|
||||
|
||||
Reference in New Issue
Block a user