新建工程

PS E:\development> uv init news_checker
Initialized project `news-checker` at `E:\development\news_checker`
PS E:\development>

然后添加依赖

uv add smolagents


查看一下包的依赖

uv tree
PS E:\development\news_checker> uv tree
Resolved 73 packages in 2ms
news-checker v0.1.0
└── smolagents v1.3.0
    ├── duckduckgo-search v7.2.1
    │   ├── click v8.1.8
    │   │   └── colorama v0.4.6
    │   ├── lxml v5.3.0
    │   └── primp v0.10.1
    ├── e2b-code-interpreter v1.0.3
    │   ├── attrs v24.3.0
    │   ├── e2b v1.0.5
    │   │   ├── attrs v24.3.0
    │   │   ├── httpcore v1.0.7
    │   │   │   ├── certifi v2024.12.14
    │   │   │   └── h11 v0.14.0
    │   │   ├── httpx v0.28.1
    │   │   │   ├── anyio v4.8.0
    │   │   │   │   ├── idna v3.10
    │   │   │   │   └── sniffio v1.3.1
    │   │   │   ├── certifi v2024.12.14
    │   │   │   ├── httpcore v1.0.7 (*)
    │   │   │   └── idna v3.10
    │   │   ├── packaging v24.2
    │   │   ├── protobuf v5.29.3
    │   │   ├── python-dateutil v2.9.0.post0
    │   │   │   └── six v1.17.0
    │   │   └── typing-extensions v4.12.2
    │   └── httpx v0.28.1 (*)
    ├── gradio v5.12.0
    │   ├── aiofiles v23.2.1
    │   ├── anyio v4.8.0 (*)
    │   ├── audioop-lts v0.2.1
    │   ├── fastapi v0.115.6
    │   │   ├── pydantic v2.10.5
    │   │   │   ├── annotated-types v0.7.0
    │   │   │   ├── pydantic-core v2.27.2
    │   │   │   │   └── typing-extensions v4.12.2
    │   │   │   └── typing-extensions v4.12.2
    │   │   ├── starlette v0.41.3
    │   │   │   └── anyio v4.8.0 (*)
    │   │   └── typing-extensions v4.12.2
    │   ├── ffmpy v0.5.0
    │   ├── gradio-client v1.5.4
    │   │   ├── fsspec v2024.12.0
    │   │   ├── httpx v0.28.1 (*)
    │   │   ├── huggingface-hub v0.27.1
    │   │   │   ├── filelock v3.16.1
    │   │   │   ├── fsspec v2024.12.0
    │   │   │   ├── packaging v24.2
    │   │   │   ├── pyyaml v6.0.2
    │   │   │   ├── requests v2.32.3
    │   │   │   │   ├── certifi v2024.12.14
    │   │   │   │   ├── charset-normalizer v3.4.1
    │   │   │   │   ├── idna v3.10
    │   │   │   │   └── urllib3 v2.3.0
    │   │   │   ├── tqdm v4.67.1
    │   │   │   │   └── colorama v0.4.6
    │   │   │   └── typing-extensions v4.12.2
    │   │   ├── packaging v24.2
    │   │   ├── typing-extensions v4.12.2
    │   │   └── websockets v14.1
    │   ├── httpx v0.28.1 (*)
    │   ├── huggingface-hub v0.27.1 (*)
    │   ├── jinja2 v3.1.5
    │   │   └── markupsafe v2.1.5
    │   ├── markupsafe v2.1.5
    │   ├── numpy v2.2.1
    │   ├── orjson v3.10.14
    │   ├── packaging v24.2
    │   ├── pandas v2.2.3
    │   │   ├── numpy v2.2.1
    │   │   ├── python-dateutil v2.9.0.post0 (*)
    │   │   ├── pytz v2024.2
    │   │   └── tzdata v2024.2
    │   ├── pillow v11.1.0
    │   ├── pydantic v2.10.5 (*)
    │   ├── pydub v0.25.1
    │   ├── python-multipart v0.0.20
    │   ├── pyyaml v6.0.2
    │   ├── ruff v0.9.2
    │   ├── safehttpx v0.1.6
    │   │   └── httpx v0.28.1 (*)
    │   ├── semantic-version v2.10.0
    │   ├── starlette v0.41.3 (*)
    │   ├── tomlkit v0.13.2
    │   ├── typer v0.15.1
    │   │   ├── click v8.1.8 (*)
    │   │   ├── rich v13.9.4
    │   │   │   ├── markdown-it-py v3.0.0
    │   │   │   │   └── mdurl v0.1.2
    │   │   │   └── pygments v2.19.1
    │   │   ├── shellingham v1.5.4
    │   │   └── typing-extensions v4.12.2
    │   ├── typing-extensions v4.12.2
    │   └── uvicorn v0.34.0
    │       ├── click v8.1.8 (*)
    │       └── h11 v0.14.0
    ├── jinja2 v3.1.5 (*)
    ├── markdownify v0.14.1
    │   ├── beautifulsoup4 v4.12.3
    │   │   └── soupsieve v2.6
    │   └── six v1.17.0
    ├── openai v1.59.7
    │   ├── anyio v4.8.0 (*)
    │   ├── distro v1.9.0
    │   ├── httpx v0.28.1 (*)
    │   ├── jiter v0.8.2
    │   ├── pydantic v2.10.5 (*)
    │   ├── sniffio v1.3.1
    │   ├── tqdm v4.67.1 (*)
    │   └── typing-extensions v4.12.2
    ├── pandas v2.2.3 (*)
    ├── pillow v11.1.0
    ├── python-dotenv v1.0.1
    ├── requests v2.32.3 (*)
    ├── rich v13.9.4 (*)
    └── transformers v4.48.0
        ├── filelock v3.16.1
        ├── huggingface-hub v0.27.1 (*)
        ├── numpy v2.2.1
        ├── packaging v24.2
        ├── pyyaml v6.0.2
        ├── regex v2024.11.6
        ├── requests v2.32.3 (*)
        ├── safetensors v0.5.2
        ├── tokenizers v0.21.0
        │   └── huggingface-hub v0.27.1 (*)
        └── tqdm v4.67.1 (*)
(*) Package tree already displayed

然后切到vscode

记得切到venv里面去

from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel


def main():
    agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
    agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
    print("Hello from news-checker!")


if __name__ == "__main__":
    main()

运行官方的例子,但是报错了

 https://github.com/huggingface/smolagents 

然后看文档吧:

 https://huggingface.co/docs/smolagents/index 

哎,用本地的吧

curl -sSL https://ollama.com/install.sh | bash

wsl2里面装的还是个0.5.1呢

先更新,然后看一下ollama的地址

 https://ollama.com/library/qwen2.5-coder 

更新完了,0.5.7

ollama run qwen2.5-coder

==================

安装一个依赖:

uv pip install litellm

有报错

然后看一下:

 https://docs.litellm.ai/docs/providers/ollama 

需要加前缀

然后发现确实是代理client那边阻碍了

这次就疯狂读写以及加载了

from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel,LiteLLMModel
import os
os.environ['DEEPSEEK_API_KEY'] = "xxxxxx"

def main():
    model = LiteLLMModel(
        model_id="deepseek/deepseek-chat", # This model is a bit weak for agentic behaviours though
    )
    agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model, add_base_tools=True)
    agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
    print("Hello from news-checker!")


if __name__ == "__main__":
    main()

算了算了,放弃放弃

折腾这些干啥,直接看了一下可以用deepseek的

PS E:\development\news_checker> & E:/development/news_checker/.venv/Scripts/python.exe 
e:/development/news_checker/hello.py
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, 
configuration and file/data utilities can be used.
E:\development\news_checker\.venv\Lib\site-packages\pydantic\_internal\_config.py:345: 
UserWarning: Valid config keys have changed in V2:
* 'fields' has been removed
  warnings.warn(message, UserWarning)
╭────────────────────────────────────────────────────────────────────────────────────────────── New run ────────
───────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                  
                                    │
│ How many seconds would it take for a leopard at full speed to run through Pont des Arts?                                                                         
                                    │
│                                                                                                                                                                  
                                    │
╰─ LiteLLMModel - deepseek/deepseek-chat ────────────────────────────────────────────────────────────────────────
──────────────────────────────────────────────────────────────────────────────────────╯
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 0 ━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ─ Executing this code: ───────────────────────────────────────────────────────────────────────────────────────
 ────────────────────────────────────────────────────────────────────────────────────────
  pont_length = web_search(query="length of Pont des Arts")                                                                                                        
                                     
  print(pont_length)                                                                                                                                               
                                     
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ───────────────────────────────────────────────────────────────────────────────────────
Execution logs:
## Search Results

[Pont des Arts - Wikipedia](https://en.wikipedia.org/wiki/Pont_des_Arts)
The Pont des Arts (French pronunciation: [pɔ̃ dez‿aʁ]) or Passerelle des Arts ([pasʁɛl-]) is a pedestrian bridge
 in Paris which crosses the River Seine. It links tthe Institut de France and the central
square ( cour carrée ) of the Palais du Louvre , (which had been termed the "Palais des Arts" under the First 
French Empire ).

[10 Picturesque Facts About The Pont Des Arts](https://art-facts.com/pont-des-arts-facts/)
Today, the number of arches has been reduced to just 7 in order to align it with the Pont Neuf, the oldest stan
ding bridge in Paris, which is located just east of the Pont des Arts at the western tip
of the "Île de la Cité.". Even though the bridge doesn't look that big at first sight, it still has a length of 
155 meters (509 feet) and a width of 11 meters (36 feet).

[Pont des Arts, Paris, France - LatLong](https://www.latlong.net/place/pont-des-arts-paris-france-32945.html)
Pont des Arts, Paris, France. Latitude and longitude coordinates are: 48.858334, 2.337369. Pont des Arts is a s
cenic pedestrian bridge over the Seine River in Paris, France. The bridge connects the
Musée du Louvre and the Institut de France. It has a length of 155 m (509 ft) and a width of 11 m (36 ft). It w
as constructed between 1981 and 1984.

[17 Famous Bridges in France: Must-See Wonders! - Salut from Paris](https://www.salutfromparis.com/famous-bridg
es-in-france/)
(built in 2004, 2460m length) Millau Viaduct in Aveyron - the world's tallest bridge. The Millau Viaduct is an 
engineering gem, standing tall in the heart of the Tarn Valley, ... #10 Pont des Arts,
Paris (initial construction between 1801 and 1804, 155m length) Pont des Arts.

[The Unique Architecture of the Pont des Arts in Paris](https://www.parisartstravel.com/the-unique-architecture
-of-the-pont-des-arts-in-paris/)
The bridge is composed of nine arches and spans approximately 155 meters in length. Its iron structure, adorned 
with numerous decorative details, gives it an elegant and romantic appearance. ... The
Pont des Arts was first opened in 1804; however, the current bridge that we see today is a reconstruction dating
 back to 1984. During the 1980s ...

[Love Lock bridge in Paris then & now: The Pont des Arts](https://cosmopoliclan.com/travel-with-kids/inspiration
/love-lock-bridge-paris-pont-des-arts/)
The Pont des Arts or Passerelle des Arts is the pedestrian bridge over the Seine that connects the Louvre Museum o
n the Right bank to the Institut de France on the Left Bank.As a result, it connects
the 1st and the 6th Paris arrondissements. It is flanked by the Pont du Carrousel downstream and by the Pont-Neuf
 and the Île de la Cité, home to the Notre Dame cathedral, upstream.

[Pont des Arts - The Love Bridge](https://www.tourdefrance-bridges.com/post/pont-des-arts-the-love-bridge)
Context:The Pont des Arts, originally a cast iron arch bridge, known more often as the "Love Bridge," crosses the S
eine river in Paris, connecting the Louvre to the Institut de Paris, formerly the
Collèges des quatre Nations. ... The original bridge had 9 arches, was 155m in length and 11m wide and was made usi
ng cast iron. The number of ...

[Exploring the History of the Pont des Arts in Paris](https://www.parisartstravel.com/exploring-the-history-of-the-
pont-des-arts-in-paris/)
This new bridge featured seven arches and a length of 155 meters. The Pont des Arts continued to evolve with the ci
ty's changing needs. In the 20th century, the bridge faced increased traffic demands,
leading to rising concerns about its stability. As a result, it underwent another major renovation in 1984, modern
izing the structure and ...

[Pont des Arts in Paris - Misadventures with Andi](https://misadventureswithandi.com/pont-des-arts-in-paris/)
The new bridge would retain its name as Pont des Arts, but have 7 arches instead of the original 9, and would be sup
ported by steel instead of cast iron. The Love Lock Bridge. Paris, the city of love,
has multiple romantic spots scattered across its length and breadth, but perhaps the most romantic is the Pont des A
rts. With its proximity to ...

[Pont des Arts, Paris, France - planerGO](https://planergo.com/en/sights/pont-des-arts/)
The Pont des Arts or Passerelle des Arts is a pedestrian bridge in Paris which crosses the Seine River. It links the
 Institut de France and the central square (cour carrée) of the palais du Louvre,
(which had been termed the "Palais des Arts" under the First Empire).Between 1802 and 1804, a nine-arch metallic br
idge for pedestrians was constructed at the location of the present day Pont des ...

Out: None
[Step 0: Duration 6.58 seconds| Input tokens: 2,091 | Output tokens: 109]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ─ Executing this code: ────────────────────────────────────────────────────────────────────────────────────────────
 ─────────────────────────────────────────────────────────────────────────────────── 
  leopard_speed = web_search(query="speed of a leopard at full speed")                                                                                             
                                     
  print(leopard_speed)                                                                                                                                             
                                     
 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ────────────────────────────────────────────────────────────────────────────────── 
Execution logs:
## Search Results

[How Fast Are Leopards? Top Speeds and How It Compares ... - AZ Animals](https://a-z-animals.com/blog/how-fast-leo
pards-top-speeds-how-compares-other-big-cats/)   
Cats of all sizes are known for their stealth, agility, and speed. We all know cheetahs take the cake when it come
s to their record-breaking speed. But what about leopards? They are quick climbers,
sneaky hunters, and pretty fast on land, but just how fast? Leopards can run up to speeds of 36 miles per hour.

[How Fast Can a Leopard Run? It's Slower than Most of Its Prey](https://africafreak.com/how-fast-can-a-leopard-run)
African leopards have a top speed of 56-60 km/h (35-37 mph). That's significantly slower than cheetahs and lions,
 as well as being slower than a lot of its prey. But this top speed isn't the full
story. The leopard is one of the greatest predators on the African savannah and speed is just one piece of its hu
nting prowess.

[How Fast Can a Leopard Run? A Fascinating Look at Their Speed](https://tiger-universe.com/blogs/tiger-blog/how-fast
-can-a-leopard-run)
The nimble leopard, known for its remarkable leopard speed, shows how evolution shaped top predators. These animals 
can dash at 36 mph , making them some of the most skilled hunters. Their fast pace
and agility let them thrive in different places, from open savannas to thick forests.

[How fast can a leopard run per hour? - Quick-Advice.com](https://yourquickadvice.com/how-fast-can-a-leopard-run-per-hour/)
The average top speed of the Leopard is apparently 88.5 kilometres per hour / 55 miles per hour. How fast can a Ja
guar run? 80 km/hMaximum Jaguar/Speed. Is Usain Bolt faster than a leopard?
"Polka-dotted missile" rockets to 61 miles an hour. Sarah the cheetah has shattered the world record for the standin
g 100-meter dash, clocking a time of ...       

[Leopard Top Speed: How Fast Can They Run](https://womeninbusiness.byu.edu/leopard-top-speed_22663.html)
Discover the remarkable speed of leopards! Learn about the leopard top speed, how fast they can run, and what makes 
them agile hunters. Explore the factors influencing their velocity, including
habitat, prey, and physical attributes. Get insights into the incredible acceleration and deceleration of these maj
estic big cats, and understand their place in the animal kingdom.

[Unraveling the Speed of Leopards: How Fast Can They Actually Run?](https://startingrun.com/unraveling-the-speed-of-l
eopards-how-fast-can-they-actually-run/)      
Environmental and situational factors, including terrain, prey's size and speed, climatic conditions, fatigue, age, a
nd health, significantly influence the leopard's speed. Compared to other big cats
such as lions, cheetahs, jaguars, and tigers, leopards hold a respectable position with a top speed of 58 km/h (36 mp
h), showcasing a ...

[How fast can leopards run and how agile are they? - WildLifeFAQs](https://wildlifefaq.com/leopard-speed-and-agility/)
The Speed and Agility of Amur Leopards. Amur leopards, a subspecies of leopard, are known for their exceptional speed a
nd agility. These magnificent creatures can reach speeds of almost 37 miles per
hour (58 km/h), allowing them to swiftly chase down prey and escape potential threats.

[The Power of the Leopard: Strength, Speed, and Symbolism](https://worlddeer.org/the-power-of-the-leopard-strength-spe
ed-and-symbolism/)
Speed and Hunting Techniques. The leopard is also one of the fastest cats, capable of running up to 35 mph (56 km/h) 
in short bursts. This speed, combined with their agility, makes leopards
exceptionally skilled hunters. Unlike lions or tigers, leopards rely on stealth and quick, decisive strikes to take 
down their prey. They typically stalk ...      

[How Fast Can a Leopard Run (Average Speed) - brotherspets.com](https://brotherspets.com/how-fast-can-a-leopard-run/)
How Fast Can a Leopard Run? Leopards are known for their speed and agility, and they are capable of reaching impressive
 top speeds when they need to. According to various sources, leopards can run at
speeds ranging from 30-56 mph (48-90 km/h) with an average speed of 58 km/h.

[How Fast Is A Leopard? - Name That Animal](https://www.namethatanimal.com/post/how-fast-is-a-leopard)
Leopards are incredibly fast runners and can reach speeds of up to 58 kilometers per hour (36 mph). They are able to 
run at these high speeds for short distances, which allows them to chase down prey
that is trying to escape. Leopards have long, muscular legs that are built for speed and allow them to cover large di
stances quickly.In addition to their speed, leopards are also incredibly agile ...

Out: None
[Step 1: Duration 4.40 seconds| Input tokens: 5,520 | Output tokens: 190]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 2 ━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 ─ Executing this code: ──────────────────────────────────────────────────────────────────────────────────────────────
 ─────────────────────────────────────────────────────────────────────────────────
  # Convert leopard speed from km/h to m/s                                                                                                                         
                                     
  leopard_speed_kmh = 58                                                                                                                                           
                                     
  leopard_speed_ms = leopard_speed_kmh * (1000 / 3600)  # 1 km/h = 1000 m / 3600 s                                                                                 
  # Convert leopard speed from km/h to m/s                                                                                                                         
                                     
  leopard_speed_kmh = 58                                                                                                                                           
                                     
  leopard_speed_ms = leopard_speed_kmh * (1000 / 3600)  # 1 km/h = 1000 m / 3600 s                                                                                 
                                     
  leopard_speed_kmh = 58                                                                                                                                           
                                     
  leopard_speed_ms = leopard_speed_kmh * (1000 / 3600)  # 1 km/h = 1000 m / 3600 s                                                                                 
                                     
                                                                                                                                                                   
  leopard_speed_kmh = 58                                                                                                                                           
                                     
  leopard_speed_ms = leopard_speed_kmh * (1000 / 3600)  # 1 km/h = 1000 m / 3600 s                                                                                 
                                     
                                                                                                                                                                   
                                     
  leopard_speed_ms = leopard_speed_kmh * (1000 / 3600)  # 1 km/h = 1000 m / 3600 s                                                                                 
                                     
                                                                                                                                                                   
                                     
                                                                                                                                                                   
                                     
  # Calculate time to run through Pont des Arts                                                                                                                    
                                     
  pont_length_m = 155                                                                                                                                              
                                     
  time_seconds = pont_length_m / leopard_speed_ms                                                                                                                  
                                     
                                                                                                                                                                   
                                     
  final_answer(time_seconds)                                                                                                                                       
                                     
 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ─────────────────────────────────────────────────────────────────────────────────────
Out - Final answer: 9.620689655172415
[Step 2: Duration 6.06 seconds| Input tokens: 10,209 | Output tokens: 394]
Hello from news-checker!
PS E:\development\news_checker>

然后最终的结果是什么?

9.620689655172415秒,一只猎豹就可以通过巴黎的那个艺术桥,整个过程其实都是跑python,有点意思哈