Well i want to know if its possible to use my custom assistant instead of the general openIA API that answers everything from intenet la chatGPT but my assistant in playground can analize documents,xlsx,jsonl etc… so i want to use it in my project but idk if its possible this is my working service class
using OpenAI_API;
using OpenAI_API.Completions;
using proyectoChat.Models;
namespace proyectoChat.Services
{
public class AnswerGeneratorService : IAnswerGeneratorServices
{
private readonly string apikey = “apikey:)”;
private readonly OpenAIAPI _openai;
private readonly FQService _faqService;
public AnswerGeneratorService(OpenAIAPI openai, FQService faqService)
{
_openai = openai;
_faqService = faqService;
}
public async Task<string> GenerateAnswer(string prompt)
{
string answer = string.Empty;
try
{
CompletionRequest completion = new CompletionRequest();
completion.Prompt = prompt;
completion.MaxTokens = 2000;
completion.Model = "gpt-3.5-turbo-instruct"; // Usar el modelo correcto
var result = await _openai.Completions.CreateCompletionAsync(completion);
if (result != null)
{
foreach (var item in result.Completions)
{
answer = item.Text;
}
}
}
catch (Exception ex)
{
// Manejar errores según tus necesidades
Console.WriteLine($"Error: {ex.Message}");
answer = $"Error: {ex.Message}";
}
return answer;
}
public async Task<string> GetFQAnswer(string question)
{
// Lógica para obtener respuestas de las preguntas frecuentes
return await Task.Run(() => _faqService.GetAnswerForQuestion(question));
}
}
}