Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Build a Weather Chatbot with DeepSeek v3 and OpenAI SDK: A Step-by-Step Guide

In this tutorial, we'll walk through creating a weather chatbot using DeepSeek v3 and OpenAI SDK for .NET. The complete source code can be found in this GitHub repository Prerequisites .NET SDK (8.0 or later) DeepSeek API key…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In this tutorial, we'll walk through creating a weather chatbot using DeepSeek v3 and OpenAI SDK for .NET. The complete source code can be found in this GitHub repository






Prerequisites




  • .NET SDK (8.0 or later)

  • DeepSeek API key (You can sign up for an account with ¥10 credit at DeepSeek






Create a New Console Project



First, let's set up our project by creating a new console application and installing required OpenAI SDK packages:




dotnet new console -n WeatherChatbot
cd WeatherChatbot
dotnet add package OpenAI









Setting Up the DeepSeek Client



Instead of using the default OpenAI endpoints, we'll configure our client to use DeepSeek's API. The DeepSeek API is compatible with the OpenAI API, so we can use the OpenAI SDK to connect to it:




var option = new OpenAIClientOptions
{
// Set the DeepSeek API endpoint
Endpoint = new ("https://api.deepseek.com"),
};
var client = new OpenAIClient(new ApiKeyCredential(DEEP_SEEK_API_KEY), option);

// use deepseek-chat model which points to the latest v3 model
var chatClient = client.GetChatClient("deepseek-chat");









Defining Function Tools



One of the key features we'll be using is the ability to define "tools" - functions that the language model can call when it needs specific information. We'll create one tool to retreive dummy weather information for a given location:




var getCurrentWeatherTool = ChatTool.CreateFunctionTool(
functionName: nameof(GetCurrentWeather),
functionDescription: "Get the current weather in a given location",
functionParameters: BinaryData.FromBytes("""
{
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. Boston, MA"
},
"unit": {
"type": "string",
"enum": [ "celsius", "fahrenheit" ],
"description": "The temperature unit to use. Infer this from the specified location."
}
},
"required": [ "location" ]
}
"""u8.ToArray())
);









Implementing the Chat Loop



The heart of our chatbot is the conversation loop. Here's how we handle the interaction:




  1. Initialize the conversation with a user message

  2. Process the message using the DeepSeek model

  3. Handle any tool calls requested by the model

  4. Continue the conversation based on the model's response




var messages = new List<ChatMessage>()
{
new UserChatMessage("What's the weather like in San Francisco?"),
};

bool requiresAction;

do
{
requiresAction = false;
var useToolCall = messages.Last() is not ToolChatMessage;
var completion = useToolCall
? await chatClient.CompleteChatAsync(messages, new () { Tools = {getCurrentWeatherTool}})
: await chatClient.CompleteChatAsync(messages);

// Handle different completion scenarios
switch (completion.Value.FinishReason)
{
case ChatFinishReason.Stop:
{
messages.Add(new AssistantChatMessage(completion));
Console.WriteLine(completion.Value.Content[0].Text);
break;
}
case ChatFinishReason.ToolCalls:
{
// Handle tool calls
// ...
}
// Handle other cases
}
} while (requiresAction);









Implementing the Weather Functions



For this example, we've implemented simple placeholder functions for getting weather information:




static string GetCurrentWeather(string location, string unit = "celsius")
{
// Call the weather API here
return $"The weather in {location} is 72 degrees {unit}.";
}






In a production environment, you'd want to replace these with actual API calls to weather and location services.






Run the Chatbot



Now that we've set up our chatbot, we can run it and see the output:



Image description

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Build a Weather Chatbot with DeepSeek v3 and OpenAI SDK: A Step-by-Step Guide
id: c52956d4-3ac4-4a81-b744-1deadf56719e
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-27
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-27"
        description = "YARA Signature for "
    strings:
        $str = "Build a Weather Chatbot with D" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Build a Weather Chatbot with DeepSeek v3")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Build a Weather Chatbot with DeepSeek v3*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Build a Weather Chatbot with DeepSeek v3"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

CTI Threat Relationship Graph3 Knoten / 2 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Analyse für identifizierte Bedrohung auf Basis von Live-CTI (ENISA EUVD): CVSS 0.0 · EPSS 0.0% · CISA KEV: nein. Handlungsableitung aus den verlinkten Hersteller-Quellen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Build a Weather Chatbot with DeepSeek v3 and OpenAI SDK: A Step-by-Step Guide

Thematisch verwandte Begriffe: Build, Weather, Chatbot, with · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-100739 | A vulnerability was detected in mathurvishal CloudClassroom-PHP-Project…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag