Programmatically add website content to OpenAI with C#

题意:使用 C# 以编程方式将网站内容添加到 OpenAI。

问题背景:

Our goal is to have a ChatGPT answer questions about our website's content.

我们的目标是让 ChatGPT 回答关于我们网站内容的问题。

We are trying to integrate something similar to a tutorial by Open AI:

我们正在尝试集成类似于 OpenAI 提供的教程的东西

How to build an AI that can answer questions about your website. I've been converting the code from Python to C# and all has been pretty successful so far. In detail we are storing the files in Azure Storage blobs.

如何构建一个可以回答关于你的网站问题的 AI。我已经将代码从 Python 转换为 C#,到目前为止一切都非常成功。详细来说,我们将文件存储在 Azure Storage blobs 中。

As I've gotten to the end of this, I noticed that for every question the embeddings are being sent as the context (pardon if that's not correctly worded). Our website has 5000+ pages with lots of content so I feel like this is not correct to what we want.

在完成这个过程后,我注意到每个问题的上下文都被发送了嵌入(如果表述不准确请见谅)。我们的网站有超过 5000 页的内容,所以我觉得这样做可能不符合我们的需求。

Is there a way in C# to give (or maybe it's called 'train') our model this data once so that questions do not need to continuously provide it for every question? We are using OpenAI and not Azure OpenAI but all the samples I find concerning using my own data are using Azure OpenAI and Azure Cognitive Search, and even then it seems like they are feeding the data for each question.

在 C# 中是否有办法一次性给我们的模型提供这些数据(或许称之为"训练"),这样提问时就不需要每次都提供这些数据?我们使用的是 OpenAI 而不是 Azure OpenAI,但我找到的所有关于使用自己数据的示例都是关于 Azure OpenAI 和 Azure Cognitive Search 的,即便如此,它们似乎还是在每个问题中都提供数据

cs 复制代码
import Azure.AI.OpenAI

var apiKey = "<my api key>";
var client = new OpenAIClient(apiKey);
var prompt = "<question about website>";

var options = new ChatCompletionOptions {
    Messages = {
        new ChatMessage(ChatRole.User, prompt),
    },
    /*
    Not currently working for some reason, further inspection needed;
    - Is it because we need Azure OpenAI instead?;
    Receiving the following error:
        
        - Azure.RequestFailedException: Invalid URL (POST /v1/extensions/chat/completions)
        - Status: 404 (Not Found)


    AzureExtensionsOptions = new AzureChatExtensionsOptions {
        Extensions = {
            new Azure CognitiveSearchExtensionConfiguration {
                SearchEndpoint = new Uri("<my search url>"),
                IndexName = "<my index name>",
                SearchKey = new AzureKeyCredential("<my search key>"),
            }
        }
    }*/
};

var response = await GetChatCompletionsAsync("gpt-3.5-turbo", options);

foreach (var choice in response.Value.Choices) {
    Console.WriteLine(choice.Message.Content);
}

问题解决:

We finally applied for and started using Azure Open AI and Azure Cognitive Search. The results are huge! Results are now in 2-3 seconds.

我们终于申请并开始使用 Azure OpenAI 和 Azure Cognitive Search。结果非常显著!现在结果只需 2-3 秒

相关推荐
骑着蜗牛撵大象32743 分钟前
2026 后端 AI 工程化:Spring AI 管调用、MCP 管工具、Agent 内嵌管自治
java·人工智能·后端·spring·ai·可观测性·mcp
aichitang20242 小时前
代数拓扑学与现代前沿视角
考研·算法·数学建模·ai·拓扑学·高考
遇码2 小时前
2026-11-01-daw-retry-banner-body
人工智能·ai·rust·数据分析·大模型·agent
吴凡wudianmei3 小时前
从 0 搭一个 AI Agent(三):SSE 流式输出,让 AI 边想边说
架构·llm·openai
rich_Chan.4 小时前
【2026 实操】bl video edit 教程:已拍素材改风格换颜色全流程,含输出规格、角标自查
人工智能·ai·云计算·aigc
AI日报派送佬4 小时前
2026年11月01日AI行业日报|可灵AI198亿融资落地、DeepSeek开源超级智能体、Anthropic取消Ultra时长限制
人工智能·开源·openai·deepseek·anthropic·ai日报
小七-七牛开发者4 小时前
AI Agent 的安全风险,正在从 Prompt 扩展到运行环境
ai·agent·security·权限管理·cursor
全栈练习生4 小时前
大规模智能体仿真
python·ai
Anesthesia丶5 小时前
基于 Qwen3-TTS 的多语言智能配音 Web 应用(Qwen3 TTS Studio)
python·ai·qwen-tts·agci
恩喜玛生物7 小时前
蛋白质结构层级:从氨基酸序列到α螺旋、β折叠与多亚基组装
ai