Changed to target Tenatch endpoint
Browse files
app.py
CHANGED
@@ -8,13 +8,13 @@ from dotenv import load_dotenv, find_dotenv
|
|
8 |
_ = load_dotenv(find_dotenv())
|
9 |
|
10 |
|
11 |
-
databricks_token = os.getenv('
|
12 |
-
model_uri = "
|
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 +30,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 +44,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,24 +58,28 @@ 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 |
-
|
71 |
-
"
|
72 |
-
"
|
73 |
-
"
|
|
|
74 |
headers = {
|
75 |
"Authorization": f"Bearer {databricks_token}",
|
76 |
"Content-Type": "application/json",
|
77 |
}
|
78 |
-
ds_dict = {'dataframe_split': dataset.to_dict(orient='split')} if isinstance(dataset, pd.DataFrame) else create_tf_serving_json(dataset)
|
79 |
data_json = json.dumps(ds_dict, allow_nan=True)
|
80 |
print("***ds_dict: ")
|
81 |
print(ds_dict)
|
@@ -121,8 +125,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()
|
|
|
8 |
_ = load_dotenv(find_dotenv())
|
9 |
|
10 |
|
11 |
+
databricks_token = os.getenv('TENATCH_TOKEN')
|
12 |
+
model_uri = "http://15.152.197.215/v1/completions"
|
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 is being discussed in the
|
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 |
|
31 |
### Instruction:
|
32 |
You are demanding customer
|
33 |
+
Determine the product or solution, the problem being solved, features, target customer that is being discussed in the
|
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 |
|
45 |
### Instruction:
|
46 |
You are demanding customer
|
47 |
+
Determine the product or solution, the problem being solved, features, target customer that is being discussed in the
|
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 |
"""
|
59 |
|
60 |
def extract_json(gen_text, n_shot_learning=0):
|
61 |
+
if(n_shot_learning == -1) :
|
62 |
+
start_index = 0
|
63 |
+
else :
|
64 |
+
start_index = gen_text.index("### Response:\n{") + 14
|
65 |
if(n_shot_learning > 0) :
|
66 |
for i in range(0, n_shot_learning):
|
67 |
gen_text = gen_text[start_index:]
|
68 |
start_index = gen_text.index("### Response:\n{") + 14
|
69 |
+
end_index = gen_text.find("}\n\n### ") + 1
|
70 |
return gen_text[start_index:end_index]
|
71 |
|
72 |
def score_model(model_uri, databricks_token, prompt):
|
73 |
+
ds_dict={
|
74 |
+
"model": "debisoft/mpt-7b-awq-tester",
|
75 |
+
"prompt": prompt,
|
76 |
+
"temperature": 0.5,
|
77 |
+
"max_tokens": 1000}
|
78 |
headers = {
|
79 |
"Authorization": f"Bearer {databricks_token}",
|
80 |
"Content-Type": "application/json",
|
81 |
}
|
82 |
+
#ds_dict = {'dataframe_split': dataset.to_dict(orient='split')} if isinstance(dataset, pd.DataFrame) else create_tf_serving_json(dataset)
|
83 |
data_json = json.dumps(ds_dict, allow_nan=True)
|
84 |
print("***ds_dict: ")
|
85 |
print(ds_dict)
|
|
|
125 |
print("***total_prompt:")
|
126 |
print(total_prompt)
|
127 |
response = get_completion(total_prompt)
|
128 |
+
gen_text = response["choices"][0]["text"]
|
129 |
+
return json.dumps(extract_json(gen_text, -1))
|
130 |
|
131 |
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")
|
132 |
iface.launch()
|