54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using LinkToolAddin.host.llm;
|
|
using LinkToolAddin.host.llm.entity;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace LinkToolAddin.resource;
|
|
|
|
public class DocDb
|
|
{
|
|
public string appId {get;set;}
|
|
public string apiKey {get;set;}
|
|
|
|
public DocDb(string apiKey,KnowledgeBase knowledgeBaseEnum)
|
|
{
|
|
this.apiKey = apiKey;
|
|
appId = knowledgeBase[knowledgeBaseEnum];
|
|
}
|
|
|
|
public enum KnowledgeBase
|
|
{
|
|
ArcGISProHelpDoc,
|
|
ArcGISProToolDoc,
|
|
TaskPlanningDoc,
|
|
ArcGISProApplicantExample
|
|
}
|
|
|
|
public Dictionary<KnowledgeBase, string> knowledgeBase = new Dictionary<KnowledgeBase, string>
|
|
{
|
|
{KnowledgeBase.ArcGISProHelpDoc,"6a77c5a68de64f469b79fcdcde9d5001"}
|
|
};
|
|
|
|
public async Task<KnowledgeResult> Retrieve(string query)
|
|
{
|
|
Llm bailian = new Bailian
|
|
{
|
|
api_key = apiKey,
|
|
app_id = appId,
|
|
};
|
|
var commonInput = new CommonInput
|
|
{
|
|
Input = new Input
|
|
{
|
|
Prompt = query
|
|
},
|
|
Parameters = new Debug(),
|
|
Debug = new Debug()
|
|
};
|
|
string responseBody = await bailian.SendApplicationAsync(commonInput);
|
|
ApplicationOutput result = JsonConvert.DeserializeObject<ApplicationOutput>(responseBody);
|
|
KnowledgeResult knowledgeResult = JsonConvert.DeserializeObject<KnowledgeResult>(result.Output.Text);
|
|
return knowledgeResult;
|
|
}
|
|
} |