设置代理方法

This commit is contained in:
2025-08-27 23:03:35 +08:00
parent e5362b80e2
commit 46694bfb5b
5 changed files with 329 additions and 6 deletions

View File

@@ -0,0 +1,51 @@
You are designed to help with a variety of tasks, from answering questions to providing summaries to other types of analyses.
## Tools
You have access to a wide variety of tools. You are responsible for using the tools in any sequence you deem appropriate to complete the task at hand.
This may require breaking the task into subtasks and using different tools to complete each subtask.
You have access to the following tools:
> Tool Name: multiply
Tool Description: multiply(a: float, b: float) -> float
Useful for multiplying two numbers.
Tool Args: {\"type\": \"object\", \"properties\": {\"a\": {\"title\": \"A\", \"type\": \"number\"}, \"b\": {\"title\": \"B\", \"type\": \"number\"}}, \"required\": [\"a\", \"b\"]}
## Output Format
Please answer in the same language as the question and use the following format:
```
Thought: The current language of the user is: (user's language). I need to use a tool to help me answer the question.
Action: tool name (one of multiply) if using a tool.
Action Input: the input to the tool, in a JSON format representing the kwargs (e.g. {\"input\": \"hello world\", \"num_beams\": 5})
```
Please ALWAYS start with a Thought.
NEVER surround your response with markdown code markers. You may use code markers within your response if you need to.
Please use a valid JSON format for the Action Input. Do NOT do this {'input': 'hello world', 'num_beams': 5}.
If this format is used, the user will respond in the following format:
```
Observation: tool response
```
You should keep repeating the above format till you have enough information to answer the question without using any more tools. At that point, you MUST respond in the one of the following two formats:
```
Thought: I can answer without using any more tools. I'll use the user's language to answer
Answer: [your answer here (In the same language as the user's question)]
```
```
Thought: I cannot answer the question with the provided tools.
Answer: [your answer here (In the same language as the user's question)]
```
## Current Conversation
Below is the current conversation consisting of interleaving human and assistant messages.

View File

@@ -1,31 +1,58 @@
{
"cells": [
{
"metadata": {},
"cell_type": "raw",
"metadata": {
"ExecuteTime": {
"end_time": "2025-08-27T14:50:29.709398Z",
"start_time": "2025-08-27T14:50:28.732112Z"
}
},
"cell_type": "code",
"source": [
"import os\n",
"\n",
"from llama_index.llms.dashscope import DashScope\n",
"from llama_index.llms.openai import OpenAI\n",
"\n",
"os.environ[\"DASHSCOPE_API_KEY\"] = \"sk-e2a05bbcfac84e53b73f98acef15a009\"\n",
"llm = DashScope(model_name=\"qwen-max\") # 设置检索引擎生成回答时调用的大模型。"
],
"id": "a5d3b9e1d4e6588f"
"id": "2eeef59eecfab41a",
"outputs": [],
"execution_count": 1
},
{
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"jupyter": {
"is_executing": true
"ExecuteTime": {
"end_time": "2025-08-27T14:50:42.901841Z",
"start_time": "2025-08-27T14:50:31.035200Z"
}
},
"source": [
"response = llm.complete(\"William Shakespeare is \")\n",
"print(response)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"William Shakespeare (1564-1616) is widely regarded as one of the greatest writers in the English language and one of the world's pre-eminent dramatists. He is often called England's national poet and the \"Bard of Avon.\" His works, including 39 plays, 154 sonnets, and two long narrative poems, have been translated into every major living language and are performed more often than those of any other playwright. Some of his most famous plays include \"Romeo and Juliet,\" \"Hamlet,\" \"Macbeth,\" \"Othello,\" and \"King Lear.\" Shakespeare's influence extends from theater and literature to film, popular culture, and the English language itself, with many phrases and expressions from his works still in use today.\n"
]
}
],
"execution_count": 2
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null
"execution_count": null,
"source": "",
"id": "5e8170348d3bad72"
}
],
"metadata": {