Update app.py
Browse files
app.py
CHANGED
@@ -43,17 +43,17 @@ def run_inference_and_analysis(task, system_prompt, input_text, temperature, top
|
|
43 |
# Initialize Pixeltable
|
44 |
pxt.drop_table('mistral_prompts', ignore_errors=True)
|
45 |
t = pxt.create_table('mistral_prompts', {
|
46 |
-
'task': pxt.
|
47 |
-
'system': pxt.
|
48 |
-
'input_text': pxt.
|
49 |
-
'timestamp': pxt.
|
50 |
-
'temperature': pxt.
|
51 |
-
'top_p': pxt.
|
52 |
-
'max_tokens': pxt.
|
53 |
-
'min_tokens': pxt.
|
54 |
-
'stop': pxt.
|
55 |
-
'random_seed': pxt.
|
56 |
-
'safe_prompt': pxt.
|
57 |
})
|
58 |
|
59 |
# Insert new row into Pixeltable
|
@@ -88,21 +88,21 @@ def run_inference_and_analysis(task, system_prompt, input_text, temperature, top
|
|
88 |
'safe_prompt': safe_prompt
|
89 |
}
|
90 |
|
91 |
-
#
|
92 |
-
t
|
93 |
-
t
|
94 |
|
95 |
# Extract responses
|
96 |
-
t
|
97 |
-
t
|
98 |
|
99 |
-
#
|
100 |
-
t
|
101 |
-
t
|
102 |
-
t
|
103 |
-
t
|
104 |
-
t
|
105 |
-
t
|
106 |
|
107 |
# Retrieve results
|
108 |
results = t.select(
|
|
|
43 |
# Initialize Pixeltable
|
44 |
pxt.drop_table('mistral_prompts', ignore_errors=True)
|
45 |
t = pxt.create_table('mistral_prompts', {
|
46 |
+
'task': pxt.String,
|
47 |
+
'system': pxt.String,
|
48 |
+
'input_text': pxt.String,
|
49 |
+
'timestamp': pxt.Timestamp,
|
50 |
+
'temperature': pxt.Float,
|
51 |
+
'top_p': pxt.Float,
|
52 |
+
'max_tokens': pxt.Int,
|
53 |
+
'min_tokens': pxt.Int,
|
54 |
+
'stop': pxt.String,
|
55 |
+
'random_seed': pxt.Int,
|
56 |
+
'safe_prompt': pxt.Bool
|
57 |
})
|
58 |
|
59 |
# Insert new row into Pixeltable
|
|
|
88 |
'safe_prompt': safe_prompt
|
89 |
}
|
90 |
|
91 |
+
# Add computed columns for model responses and analysis
|
92 |
+
t.add_computed_column(open_mistral_nemo=chat_completions(model='open-mistral-nemo', **common_params))
|
93 |
+
t.add_computed_column(mistral_medium=chat_completions(model='mistral-medium', **common_params))
|
94 |
|
95 |
# Extract responses
|
96 |
+
t.add_computed_column(omn_response=t.open_mistral_nemo.choices[0].message.content.astype(pxt.String))
|
97 |
+
t.add_computed_column(ml_response=t.mistral_medium.choices[0].message.content.astype(pxt.String))
|
98 |
|
99 |
+
# Add computed columns for analysis
|
100 |
+
t.add_computed_column(large_sentiment_score=get_sentiment_score(t.ml_response))
|
101 |
+
t.add_computed_column(large_keywords=extract_keywords(t.ml_response))
|
102 |
+
t.add_computed_column(large_readability_score=calculate_readability(t.ml_response))
|
103 |
+
t.add_computed_column(open_sentiment_score=get_sentiment_score(t.omn_response))
|
104 |
+
t.add_computed_column(open_keywords=extract_keywords(t.omn_response))
|
105 |
+
t.add_computed_column(open_readability_score=calculate_readability(t.omn_response))
|
106 |
|
107 |
# Retrieve results
|
108 |
results = t.select(
|