PierreBrunelle commited on
Commit
f519aed
·
verified ·
1 Parent(s): 8561e77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -23
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.StringType(),
47
- 'system': pxt.StringType(),
48
- 'input_text': pxt.StringType(),
49
- 'timestamp': pxt.TimestampType(nullable=True),
50
- 'temperature': pxt.FloatType(nullable=True),
51
- 'top_p': pxt.FloatType(nullable=True),
52
- 'max_tokens': pxt.IntType(nullable=True),
53
- 'min_tokens': pxt.IntType(nullable=True),
54
- 'stop': pxt.StringType(nullable=True),
55
- 'random_seed': pxt.IntType(nullable=True),
56
- 'safe_prompt': pxt.BoolType(nullable=True)
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
- # Run inference with both models
92
- t['open_mistral_nemo'] = chat_completions(model='open-mistral-nemo', **common_params)
93
- t['mistral_medium'] = chat_completions(model='mistral-medium', **common_params)
94
 
95
  # Extract responses
96
- t['omn_response'] = t.open_mistral_nemo.choices[0].message.content.astype(pxt.StringType())
97
- t['ml_response'] = t.mistral_medium.choices[0].message.content.astype(pxt.StringType())
98
 
99
- # Run analysis
100
- t['large_sentiment_score'] = get_sentiment_score(t.ml_response)
101
- t['large_keywords'] = extract_keywords(t.ml_response)
102
- t['large_readability_score'] = calculate_readability(t.ml_response)
103
- t['open_sentiment_score'] = get_sentiment_score(t.omn_response)
104
- t['open_keywords'] = extract_keywords(t.omn_response)
105
- t['open_readability_score'] = calculate_readability(t.omn_response)
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(