Skip to content

Commit fcb49b8

Browse files
committed
add markdown
1 parent 71da4db commit fcb49b8

18 files changed

+138
-100
lines changed

README.en-US.md

Lines changed: 109 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,115 @@
1-
[English](README.en-US.md) | [简体中文](README.md)
1+
[简体中文](README.md) | [English](README.en-US.md)
22

33
# LLM Client for WPF
44

5-
A lightweight, open-source large language model (LLM) client built with `.NET` and `WPF`. This project provides an intuitive and feature-rich interaction tool for utilizing various LLM services. By default, it supports some GitHub Copilot service models (e.g., `GPT-4o`, `O1`, and `DeepSeek`), with planned extensions for other endpoints.
6-
7-
![项目截图](images/model_selection.png)
8-
9-
## Key Features
10-
11-
1. **Pure .NET WPF Implementation**
12-
- Built with the `MaterialDesign` library for a modern UI.
13-
- Uses `Microsoft.Extensions.AI` for seamless LLM API integration.
14-
15-
2. **Basic LLM Interaction**
16-
- Configure and interact with language models.
17-
18-
3. **Code Highlighting**
19-
- Integrated `TextmateSharp` for syntax highlighting in various programming languages.
20-
21-
4. **Context Management**
22-
- Manually manage chat context by excluding specific conversation entries without deleting them.
23-
24-
5. **Theme Switching**
25-
- Supports light and dark themes for UI.
26-
- Allows switching between different code highlighting themes.
27-
28-
6. **UI Performance Optimization**
29-
- Conversation records implement UI virtualization for improved performance with large data sets.
30-
31-
7. **Markdown Export**
32-
- Save chat history in Markdown format for sharing or archiving.
33-
34-
## Project Screenshots
35-
![项目截图](images/darkmode.png)
36-
![项目截图](images/lightmode.png)
37-
38-
## Planned Features
39-
40-
The following features are under active development:
41-
42-
1. **Multi-Endpoint Support**
43-
- Add support for other LLM endpoints, such as `Claude`.
44-
45-
2. **Chain-of-Thought (CoT) Presets**
46-
- Enable users to orchestrate predefined Chain-of-Thought (CoT) workflows for multi-step reasoning.
47-
48-
3. **Auto-CoT**
49-
- Automatically generate Chain-of-Thought processes for better handling of complex tasks.
50-
51-
4. **RAG Integration**
52-
- Introduce Retrieval-Augmented Generation (RAG) for advanced knowledge-driven generation.
53-
54-
5. **Automatic Context Management**
55-
- Offer intelligent context management, eliminating the need for manual exclusions.
56-
57-
6. **Multi-Model Output Comparison**
58-
- Compare outputs from different LLMs for better model evaluation.
59-
60-
7. **Searching Functionality**
61-
- Quickly search through chat history and knowledge base content.
62-
63-
## How to Get Involved
64-
65-
This project is still in active development. You can contribute in the following ways:
66-
67-
1. **Submit Issues or Pull Requests**: All bug reports, feature requests, or suggestions are welcome!
68-
2. **Become a Contributor**: Fork this repository and submit your changes through Pull Requests.
69-
3. **Contact the Author**: Reach out via [GitHub Issues](https://github.com/) for questions or collaboration opportunities.
70-
71-
72-
## Usage Instructions
73-
74-
> Detailed instructions on how to compile, run, and configure the project will be added.
75-
76-
## Acknowledgements
77-
78-
Special thanks to the following open-source libraries and tools:
79-
80-
- [MaterialDesignInXAML](https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit)
81-
- [TextmateSharp](https://github.com/microsoft/TextMateSharp)
82-
- [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/)
83-
- And other great tools and frameworks not listed here.
5+
A large language model (LLM) client project implemented based on `.NET` and `WPF` technology, aiming to provide a lightweight, intuitive, and feature-rich interaction tool to use various supported LLM services. The project natively supports some models provided under the GitHub Copilot service (such as `GPT-4o`, `O1`, and `DeepSeek`), and can be extended to support other service endpoints.
6+
7+
![Project Screenshot](images/model_selection.png)
8+
9+
## Pure .NET WPF Implementation
10+
I want to prove that it is feasible to build a usable, modern LLM client entirely with .NET and classic WPF👍. Most current implementations are based on python+ts😢.
11+
- Utilize `MaterialDesignThemes` for modern interface design.
12+
- Use `Microsoft.Extensions.AI` for integration with large language model APIs.
13+
- Use `Markdig.Wpf` for Markdown parsing.
14+
- Utilize `Microsoft.SemanticKernel` for core large model dialogue and RAG capabilities.
15+
- Use `ig` for reading and parsing PDF documents.
16+
- Implement `ModelContextProtocol` for MCP protocol support.
17+
- Utilize `TextMateSharp` for syntax highlighting.
18+
---
19+
## Basic Session Features
20+
**Endpoint-Model Configuration**
21+
Configuration is divided by endpoint, and users can add multiple endpoints and different models for each endpoint.
22+
The GitHub Copilot endpoint is preset, and users only need to provide a token to use it.
23+
![alt text](images/github_copilot.png)
24+
It also allows custom OpenAI API compatible endpoints. Here I added four API Endpoints:
25+
![alt text](images/openrouter.png)
26+
The above is the largest model supplier [openrouter](https://openrouter.com). You can see that besides manually configuring models, you can also fill in the model id and retrieve model-related information from openrouter, making it convenient for users.
27+
**Create a Dialogue**
28+
Select 'New Dialogue' in the bottom left corner, choose an endpoint and a model, and enter a question to start a dialogue. <img src="images/createdialog.png" alt="start dialog" style="zoom:50%;"/>
29+
![alt text](images/modelselection.png)
30+
Each model has its characteristics, and different characteristics come with different functions, such as supporting streaming output and function calls. These characteristics also influence the availability of dialogue functionalities.
31+
**Dialogue Interface**
32+
![alt text](images/dialog_ui.png)
33+
- Fine dialogue context management, users can clear history, isolate history, and exclude individual replies. Unlike those tools that automatically manage context, users completely control context transmission.
34+
- Supports message type differentiation (e.g., user messages, model replies, system messages, etc.).
35+
- Saving and loading dialogue records for long-term use and management is supported.
36+
- Resending messages is possible.
37+
- Messages can be compared, fully supporting context like function calls.
38+
- Model switching and model parameter adjustments are allowed.
39+
<img src="images/model_param.png" alt="edit param" style="zoom:60%;" />
40+
- The dialogue is searchable and highlighted in yellow, allowing quick navigation to search results.
41+
- Markdown rendering and code highlighting are supported.
42+
- Dialogues can be exported to Markdown format for easier archiving and sharing.
43+
- Supports cloning dialogues.
44+
- Supports backup and import of dialogues.
45+
- Supports UI virtualization of dialogue records to enhance performance.
46+
- Theme switching (dark mode and light mode) is supported.
47+
![Dark Mode](images/darkmode.png)
48+
![Light Mode](images/lightmode.png)
49+
- Supports code highlighting theme switching.
50+
**Dialogue Features**
51+
- Parameter changes and model switching.
52+
- Supports message resending.
53+
- Supports message comparison.
54+
- Supports corpus search and manual context addition.
55+
- Supports streaming output.
56+
- Supports function calling (including MCP).
57+
- Supports image input (images can be pasted directly into the input box).
58+
- Supports RAG function (corpus functionality is encapsulated as a function to maximize the flexibility of large models).
59+
- Supports search parameters (additional parameters are available for different API suppliers, such as OpenRouter).
60+
- Supports search tools (Function Call).
61+
- Supports Thinking switch (OpenRouter).
62+
----
63+
64+
## Fine-grained RAG
65+
Retrieval-Augmented Generation refers to enhancing the response capabilities of generative models by retrieving relevant information. In this project, the RAG feature allows users to combine external knowledge bases (e.g., documents, websites) with large language models to provide more accurate and contextually relevant responses. Unlike ordinary RAG, this project's RAG features have three significant characteristics:
66+
1. **Fine-grained Document Import**: It is known that the bottleneck of RAG lies in document preprocessing, during which much information may be lost. This project supports importing multiple file formats (such as PDF, Word, text files, etc.), providing fine-grained chunking and embedding options to ensure maximum preservation of document content integrity.
67+
2. **Function Call Integration**: The RAG feature is encapsulated as a function call, not limited to Query, but also extends to document structure queries, allowing LLM to generate Query strings based on understanding the document's overview. This fully utilizes the inferencing capability of large models, dynamically deciding when to invoke RAG functionality, thereby improving response relevance and accuracy.
68+
3. **Structured Query**: Files will not be directly split into flat chunks but parsed into structured data (e.g., chapters, paragraphs, etc.), with each node automatically generating a Summary to support more complex query strategies. The query process will selectively execute top-down or bottom-up retrieval strategies based on the structure's characteristics. The query results are also returned in a structured format, making it easier for large models to understand and use. For instance, a returned paragraph will include its chapter information, facilitating the model's contextual understanding.
69+
70+
**File Import**
71+
Users can import files through the UI interface, supporting multiple formats (currently supporting only PDF, Markdown). The file management page is as follows:
72+
![alt text](images/rag_import.png)
73+
After selecting a file, use the toggle button on the right ![alt text](images/start_button.png) to start the import process. Generally speaking, RAG encounters information loss at the first step of **file structuring**. To achieve high control over the RAG process, the file import process provides additional controls. For example, with the following PDF, you can select Margin in the interface, preview, and change the Bookmark (some PDFs have incorrect Bookmark markings).
74+
![alt text](images/pdf_extractor.png)
75+
![alt text](images/pdf_step2.png)
76+
The above image shows nodes divided according to Bookmarks; the next step generates Summaries, and finally, the file is embedded and stored in a vector database (local Sqlite). We can preview them in the end:
77+
![alt text](images/query_view.png)
78+
As shown above, the data is displayed in a tree structure, showing the Summary for Bookmark nodes and the actual content for Paragraph/Page nodes.
79+
If building fails, you can view the reason in the log:
80+
<img src="images/rag_log.png" alt="log" style="zoom:70%;" />
81+
## MCP Support
82+
- Supports adding tools via UI and Json ![Add MCP](images/mcp_add.png)
83+
- Json method formats are similar to tools like Claude Code
84+
![MCP Json](images/mcp_json.png)
85+
- After adding, you can manually refresh to obtain the tool list
86+
![MCP List](images/mcp_list.png)
87+
- MCP tools can also attach a prompt, which automatically attaches to the System Prompt when selecting that tool
88+
89+
## Project (Experimental)
90+
The project feature allows users to create and manage multiple related dialogues that share the same context. This is suitable for scenarios requiring collaboration across multiple dialogues or tracking different topics. Each project can contain multiple dialogues and can be conveniently switched and managed between them.
91+
![alt text](images/project.png)
92+
93+
## Features in Progress
94+
95+
The following features are under development:
96+
97+
1. **Predefined CoT Orchestration**
98+
- Support orchestration based on the Chain-of-Thought (CoT) reasoning process, helping users efficiently obtain multi-step reasoning outputs.
99+
100+
2. **Auto-CoT**
101+
- Automatically generate Chain-of-Thought reasoning to enhance automated processing outcomes for complex tasks.
102+
103+
3. **Automatic Context Management**
104+
- Provides intelligent context management features, eliminating the need to manually exclude historical records.
105+
## How to Contribute to the Project
106+
107+
As the project is still under development, you can contribute in the following ways:
108+
109+
1. Submit an Issue or PR: Any feedback on features, bug fixes, or suggestions for new features is highly welcomed!
110+
2. Become a Contributor: Directly fork the project and initiate a Pull Request.
111+
3. Contact the Author: For any questions or collaboration interests, you can contact me through [GitHub Issues](https://github.com/).
84112

85113
---
86114

87-
This is a project full of potential. Contributions are warmly welcomed!
115+
This is a learning project, and I appreciate your valuable feedback!

README.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
![alt text](images/openrouter.png)
2626
上面是最大的模型供应商[openrouter](https://openrouter.com),可见除了支持手动配置模型外,还可以填写模型id然后从openrouter拉取模型相关信息,方便用户。
2727
**创建对话**
28-
在左下角选择''新建对话'',选择终结点和模型,输入问题即可开始对话。
29-
![alt text](images/createdialog.png)
28+
在左下角选择''新建对话'',选择终结点和模型,输入问题即可开始对话。<img src="images/createdialog.png" alt="start dialog" style="zoom:50%;"/>
3029
![alt text](images/modelselection.png)
3130
可见每个模型都有自己的特性,不同的特性将拥有不同的功能,比如支持流式输出、支持函数调用等。这些特性也会影响对话的功能可用性。
3231
**对话界面**
@@ -37,16 +36,16 @@
3736
- 可重发消息
3837
- 可对比消息(对比时完整支持上下文如函数调用)
3938
- 可切换模型和调整模型参数
40-
- ![alt text](images/model_param.png)
39+
<img src="images/model_param.png" alt="edit param" style="zoom:60%;"/>
4140
- 可搜索对话,并以黄色高亮显示,可快速定位搜索结果
4241
- 支持Markdown渲染,支持代码高亮
4342
- 支持对话导出为Markdown格式,便于存档和分享
4443
- 支持对话克隆
4544
- 支持对话备份和导入
4645
- 支持对话记录的UI虚拟化,提升性能
4746
- 支持主题切换(暗黑模式和明亮模式)
48-
![项目截图](images/darkmode.png)
49-
![项目截图](images/lightmode.png)
47+
![暗黑模式](images/darkmode.png)
48+
![日间模式](images/lightmode.png)
5049
- 支持代码高亮主题切换
5150
**对话功能**
5251
- 参数更改、模型切换
@@ -60,13 +59,37 @@
6059
- 支持搜索参数(不同API供应商会有不同的附加参数,如OpenRouter)
6160
- 支持搜索工具(Function Call)
6261
- 支持Thinking开关(OpenRouter)
62+
----
6363

6464
## 精细RAG
6565
Retrieval-Augmented Generation 指的是通过检索相关信息来增强生成式模型的回答能力。在本项目中,RAG 功能允许用户将外部知识库(如文档、网页等)与大语言模型结合使用,以提供更准确和上下文相关的回答。不同于普通的RAG,本项目的RAG功能具三大特点:
6666
1. **精细化文件导入**:我们知道RAG瓶颈在于文档的预处理,在这个阶段可能丢失大量信息。本项目支持多种文件格式(如PDF、Word、文本文件等)的导入,并提供细粒度的分块和嵌入选项,确保最大限度地保留文档内容的完整性。
6767
2. **函数调用集成**:RAG 功能被封装为函数调用,不仅仅有Query,还有文档结构查询等功能,让LLM在理解文档概览的前提下生成Query字符串。这样可以充分利用大模型的推理能力,动态决定何时调用RAG功能,从而提升回答的相关性和准确性。
6868
3. **结构化查询**:文件不会被直接切分为扁平块,而是会被解析为结构化数据(如章节、段落等),每个节点自动生成Summary,从而支持更复杂的查询策略。查询过程会基于结构的特性,选择性地执行自顶向下或自底向上的检索策略。查询结果也会以结构化的形式返回,便于大模型理解和使用。比如,返回的某个段落将包含他的章节信息,方便模型理解上下文。
6969

70+
**文件导入**
71+
用户可以通过UI界面导入文件,支持多种格式(目前只支持PDF、Markdown)。文件的管理页面如下:
72+
![alt text](images/rag_import.png)
73+
选择文件后,通过右侧的开关按钮![alt text](images/start_button.png)可以开始实施导入。一般来说,RAG在第一步**文件的结构化**遭遇信息损失,为了实现对RAG过程的高度可控,文件的导入过程提供了额外控制。比如下面的PDF,可以在界面中选择Margin,预览和更改Bookmark(有些PDF的Bookmark标记错误)。
74+
![alt text](images/pdf_extractor.png)
75+
![alt text](images/pdf_step2.png)
76+
上图表示依据Bookmark被划分的节点,下一步会生成Summary,最终文件会被Embedding后存入矢量数据库(本地Sqlite),最终我们可以预览他们:
77+
![alt text](images/query_view.png)
78+
如上图,数据以树形结构显示,对于Bookmark节点,显示其Summary,对于Paragraph/Page节点,显示实际内容。
79+
如果构建失败,可以在日志查看原因:
80+
<img src="images/rag_log.png" alt="log" style="zoom:70%;" />
81+
## MCP 支持
82+
- 支持UI和Json方式添加工具 ![MCP添加](images/mcp_add.png)
83+
- Json方式的格式和Claude Code等工具类似
84+
![MCP Json](images/mcp_json.png)
85+
- 添加后可以手动刷新,获取工具列表
86+
![MCP列表](images/mcp_list.png)
87+
- MCP工具还可以附带一个Prompt,当选择该工具时会自动附加到System Prompt
88+
89+
## Project(Experimental)
90+
项目功能允许用户创建和管理多个相关对话,他们共享同一个上下文,适用于需要跨多个对话进行协作或跟踪不同主题的场景。每个项目可以包含多个对话,并且可以方便地在项目之间切换和管理。
91+
![alt text](images/project.png)
92+
7093
## 待完成特性
7194

7295
以下功能正在计划开发中:
@@ -79,7 +102,6 @@ Retrieval-Augmented Generation 指的是通过检索相关信息来增强生成
79102

80103
3. **自动上下文管理**
81104
- 提供上下文的智能管理功能,无需手动排除历史记录。
82-
-
83105
## 如何参与项目
84106

85107
本项目尚在开发阶段,您可以通过以下方式参与:
@@ -89,18 +111,6 @@ Retrieval-Augmented Generation 指的是通过检索相关信息来增强生成
89111
3. 联系作者:如果有任何问题或者合作意向,可以通过 [GitHub Issues](https://github.com/) 联系我。
90112

91113

92-
## 使用方法
93-
94-
> 待详细添加项目的编译、运行和配置说明。
95-
96-
## 感谢
97-
98-
感谢以下开源库和工具的支持:
99-
100-
- [MaterialDesignInXAML](https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit)
101-
- [TextmateSharp](https://github.com/microsoft/TextMateSharp)
102-
- [Microsoft.Extensions.AI](https://learn.microsoft.com/en-us/dotnet/)
103-
104114
---
105115

106-
这是一个充满潜力的项目,欢迎大家加入进来,共同扩展其应用场景
116+
这是一个学习性质的项目,请不吝赐教

images/createdialog.png

33.7 KB
Loading

images/dialog_ui.png

525 KB
Loading

images/github_copilot.png

115 KB
Loading

images/mcp_add.png

12.9 KB
Loading

images/mcp_json.png

19.4 KB
Loading

images/mcp_list.png

55.8 KB
Loading

images/model_param.png

30 KB
Loading

images/modelselection.png

121 KB
Loading

0 commit comments

Comments
 (0)