mwill-AImission commited on
Commit
018cb2f
·
verified ·
1 Parent(s): 3595adc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -1,4 +1,6 @@
 
1
 
 
2
  # Import necessary parts of our AI framework.
3
  # CodeAgent helps us build our helper agent.
4
  # HfApiModel sets up the model (the "brain") that processes text.
@@ -6,7 +8,7 @@
6
  from smolagents import CodeAgent, HfApiModel, tool
7
 
8
  # ------------------------------------------------------------------------------
9
- # Import YAML so we can load additional instructions from a file.
10
  import yaml
11
 
12
  # ------------------------------------------------------------------------------
@@ -18,11 +20,11 @@ from Gradio_UI import GradioUI
18
 
19
  # ------------------------------------------------------------------------------
20
  # Set up our AI model (the "brain" of our agent).
21
- # This model processes text prompts and generates responses.
22
  model = HfApiModel(
23
  max_tokens=2096, # Maximum length of the generated answer.
24
  temperature=0.5, # Controls how creative or focused the response is.
25
- # We use an alternative model endpoint to help if the primary model is busy.
26
  model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
27
  # (To revert to the original model, use: model_id='Qwen/Qwen2.5-Coder-32B-Instruct')
28
  custom_role_conversions=None
@@ -31,4 +33,10 @@ model = HfApiModel(
31
  # ------------------------------------------------------------------------------
32
  # Define the simplify_text tool.
33
  # This tool takes technical text and instructs the LLM to explain it in plain language.
34
- # It tells the model to break down complex ideas into simple sentences and explain technical term
 
 
 
 
 
 
 
1
+ # app.py
2
 
3
+ # ------------------------------------------------------------------------------
4
  # Import necessary parts of our AI framework.
5
  # CodeAgent helps us build our helper agent.
6
  # HfApiModel sets up the model (the "brain") that processes text.
 
8
  from smolagents import CodeAgent, HfApiModel, tool
9
 
10
  # ------------------------------------------------------------------------------
11
+ # Import YAML to load additional instructions from a file.
12
  import yaml
13
 
14
  # ------------------------------------------------------------------------------
 
20
 
21
  # ------------------------------------------------------------------------------
22
  # Set up our AI model (the "brain" of our agent).
23
+ # The model processes text prompts and generates responses.
24
  model = HfApiModel(
25
  max_tokens=2096, # Maximum length of the generated answer.
26
  temperature=0.5, # Controls how creative or focused the response is.
27
+ # We use an alternative model endpoint if the primary model is busy.
28
  model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
29
  # (To revert to the original model, use: model_id='Qwen/Qwen2.5-Coder-32B-Instruct')
30
  custom_role_conversions=None
 
33
  # ------------------------------------------------------------------------------
34
  # Define the simplify_text tool.
35
  # This tool takes technical text and instructs the LLM to explain it in plain language.
36
+ # It tells the model to break down complex ideas into simple sentences and explain technical terms in simple words.
37
+ @tool
38
+ def simplify_text(text: str) -> str:
39
+ """
40
+ Converts technical text into plain, everyday language.
41
+ It explains any technical terms (by providing a simple definition in parentheses)
42
+ and breaks down complex ideas into short, clear senten