Spaces:
Running
on
Zero
Running
on
Zero
dfa
Browse files
controllers/【リッチメニュー】取/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
【リッチメニュー】取扱商材【リッチメニュー】取扱商材
|
controllers/買取強化キャンペーン/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
買取強化キャンペーン買取強化キャンペーン
|
mysite/interpreter/prompt.py
CHANGED
@@ -9,14 +9,40 @@ from langchain_core.prompts import (
|
|
9 |
from langchain_core.messages import SystemMessage
|
10 |
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
11 |
from langchain_groq import ChatGroq
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
-
def prompt_genalate(word):
|
15 |
# Get Groq API key
|
16 |
groq_api_key = os.getenv("api_key")
|
17 |
groq_chat = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192")
|
18 |
|
19 |
-
system_prompt =
|
20 |
conversational_memory_length = 50
|
21 |
|
22 |
memory = ConversationBufferWindowMemory(
|
@@ -42,6 +68,7 @@ def prompt_genalate(word):
|
|
42 |
HumanMessagePromptTemplate.from_template("{human_input}"),
|
43 |
]
|
44 |
)
|
|
|
45 |
|
46 |
conversation = LLMChain(
|
47 |
llm=groq_chat,
|
@@ -54,4 +81,4 @@ def prompt_genalate(word):
|
|
54 |
print("User: ", user_question)
|
55 |
print("Assistant:", response)
|
56 |
|
57 |
-
return user_question+"[役割]"+response
|
|
|
9 |
from langchain_core.messages import SystemMessage
|
10 |
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
11 |
from langchain_groq import ChatGroq
|
12 |
+
from groq import Groq
|
13 |
+
|
14 |
+
def test_prompt(prompt,question):
|
15 |
+
client = Groq(api_key=os.getenv("api_key"))
|
16 |
+
completion = client.chat.completions.create(
|
17 |
+
model="llama3-8b-8192",
|
18 |
+
messages=[
|
19 |
+
{
|
20 |
+
"role": "system",
|
21 |
+
"content": prompt+" 毎回日本語で答える事"
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"role": "user",
|
25 |
+
"content": question
|
26 |
+
},
|
27 |
+
],
|
28 |
+
temperature=1,
|
29 |
+
max_tokens=1024,
|
30 |
+
top_p=1,
|
31 |
+
stream=False,
|
32 |
+
stop=None,
|
33 |
+
)
|
34 |
+
|
35 |
+
print(completion.choices[0].message)
|
36 |
+
return completion.choices[0].message.content
|
37 |
+
|
38 |
|
39 |
|
40 |
+
def prompt_genalate(word,sys_prompt="あなたはプロンプト作成の優秀なアシスタントです。答えは日本語で答えます"):
|
41 |
# Get Groq API key
|
42 |
groq_api_key = os.getenv("api_key")
|
43 |
groq_chat = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192")
|
44 |
|
45 |
+
system_prompt = sys_prompt
|
46 |
conversational_memory_length = 50
|
47 |
|
48 |
memory = ConversationBufferWindowMemory(
|
|
|
68 |
HumanMessagePromptTemplate.from_template("{human_input}"),
|
69 |
]
|
70 |
)
|
71 |
+
|
72 |
|
73 |
conversation = LLMChain(
|
74 |
llm=groq_chat,
|
|
|
81 |
print("User: ", user_question)
|
82 |
print("Assistant:", response)
|
83 |
|
84 |
+
return user_question+"[役割]"+response,response
|