Changed to target Tenatch endpoint
Browse files
app.py
CHANGED
@@ -7,14 +7,13 @@ import json
|
|
7 |
from dotenv import load_dotenv, find_dotenv
|
8 |
_ = load_dotenv(find_dotenv())
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
model_uri = "https://dbc-eb788f31-6c73.cloud.databricks.com/serving-endpoints/Mpt-7b-tester/invocations"
|
13 |
n_shot_learning = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
14 |
|
15 |
### Instruction:
|
16 |
You are demanding customer
|
17 |
-
Determine the product or solution, the problem being solved, features, target customer that
|
18 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
19 |
Finally, state if you would invest in it and elaborate on why.
|
20 |
|
@@ -30,7 +29,7 @@ Below is an instruction that describes a task, paired with an input that provide
|
|
30 |
|
31 |
### Instruction:
|
32 |
You are demanding customer
|
33 |
-
Determine the product or solution, the problem being solved, features, target customer that
|
34 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
35 |
Finally, state if you would invest in it and elaborate on why.
|
36 |
|
@@ -44,7 +43,7 @@ Thawrih brings diversity and inclusivity to the activewear market with its sport
|
|
44 |
|
45 |
### Instruction:
|
46 |
You are demanding customer
|
47 |
-
Determine the product or solution, the problem being solved, features, target customer that
|
48 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
49 |
Finally, state if you would invest in it and elaborate on why.
|
50 |
|
@@ -58,16 +57,20 @@ I am building an online community to help people to find dates.
|
|
58 |
"""
|
59 |
|
60 |
def extract_json(gen_text, n_shot_learning=0):
|
61 |
-
|
|
|
|
|
|
|
62 |
if(n_shot_learning > 0) :
|
63 |
for i in range(0, n_shot_learning):
|
64 |
gen_text = gen_text[start_index:]
|
65 |
start_index = gen_text.index("### Response:\n{") + 14
|
66 |
-
end_index = gen_text.
|
67 |
return gen_text[start_index:end_index]
|
68 |
|
69 |
def score_model(model_uri, databricks_token, prompt):
|
70 |
dataset=pd.DataFrame({
|
|
|
71 |
"prompt":[prompt],
|
72 |
"temperature": [0.5],
|
73 |
"max_tokens": [1000]})
|
@@ -121,8 +124,8 @@ Give a score for the product. Format your response as a JSON object with \
|
|
121 |
print("***total_prompt:")
|
122 |
print(total_prompt)
|
123 |
response = get_completion(total_prompt)
|
124 |
-
gen_text = response["
|
125 |
-
return json.dumps(extract_json(gen_text,
|
126 |
|
127 |
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Company"), gr.Textbox(label="Solution"), gr.Textbox(label="Customer"), gr.Textbox(label="Problem"), gr.Textbox(label="Feature"), gr.Textbox(label="Target Audience persona", lines=3)], outputs="json")
|
128 |
iface.launch()
|
|
|
7 |
from dotenv import load_dotenv, find_dotenv
|
8 |
_ = load_dotenv(find_dotenv())
|
9 |
|
10 |
+
databricks_token = os.getenv('TENATCH_TOKEN')
|
11 |
+
model_uri = "http://15.152.197.215/v1/completions"
|
|
|
12 |
n_shot_learning = f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
13 |
|
14 |
### Instruction:
|
15 |
You are demanding customer
|
16 |
+
Determine the product or solution, the problem being solved, features, target customer that is being discussed in the
|
17 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
18 |
Finally, state if you would invest in it and elaborate on why.
|
19 |
|
|
|
29 |
|
30 |
### Instruction:
|
31 |
You are demanding customer
|
32 |
+
Determine the product or solution, the problem being solved, features, target customer that is being discussed in the
|
33 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
34 |
Finally, state if you would invest in it and elaborate on why.
|
35 |
|
|
|
43 |
|
44 |
### Instruction:
|
45 |
You are demanding customer
|
46 |
+
Determine the product or solution, the problem being solved, features, target customer that is being discussed in the
|
47 |
following user prompt. State if you would use this product and elaborate on why. Also state if you would pay for it and elaborate on why.
|
48 |
Finally, state if you would invest in it and elaborate on why.
|
49 |
|
|
|
57 |
"""
|
58 |
|
59 |
def extract_json(gen_text, n_shot_learning=0):
|
60 |
+
if(n_shot_learning == -1) :
|
61 |
+
start_index = 0
|
62 |
+
else :
|
63 |
+
start_index = gen_text.index("### Response:\n{") + 14
|
64 |
if(n_shot_learning > 0) :
|
65 |
for i in range(0, n_shot_learning):
|
66 |
gen_text = gen_text[start_index:]
|
67 |
start_index = gen_text.index("### Response:\n{") + 14
|
68 |
+
end_index = gen_text.find("}\n\n### ") + 1
|
69 |
return gen_text[start_index:end_index]
|
70 |
|
71 |
def score_model(model_uri, databricks_token, prompt):
|
72 |
dataset=pd.DataFrame({
|
73 |
+
"model": "debisoft/mpt-7b-awq-tester",
|
74 |
"prompt":[prompt],
|
75 |
"temperature": [0.5],
|
76 |
"max_tokens": [1000]})
|
|
|
124 |
print("***total_prompt:")
|
125 |
print(total_prompt)
|
126 |
response = get_completion(total_prompt)
|
127 |
+
gen_text = response["choices"][0]["text"]
|
128 |
+
return json.dumps(extract_json(gen_text, -1))
|
129 |
|
130 |
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Company"), gr.Textbox(label="Solution"), gr.Textbox(label="Customer"), gr.Textbox(label="Problem"), gr.Textbox(label="Feature"), gr.Textbox(label="Target Audience persona", lines=3)], outputs="json")
|
131 |
iface.launch()
|