Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Assistants: How do I get a response? #112

Open
Samuramu opened this issue May 16, 2024 · 3 comments
Open

Help with Assistants: How do I get a response? #112

Samuramu opened this issue May 16, 2024 · 3 comments

Comments

@Samuramu
Copy link

What is wrong with my code here?

final _openAI = await chatGpt.OpenAI.instance.build(token: chatApiKey,baseOption: HttpSetup(receiveTimeout: const Duration(seconds: 15)),enableLog: true);
    print ('retrieves assistant...');
    final assistants = await _openAI.assistant.retrieves(assistantId: 'asst_zzzzzzzzzzzzzzz'); // GPT-4o
    //
    String useModel = assistants.name;
    print('assistants.name ${assistants.id}');
    
    final _request = ThreadRequest(messages: [
      {
        "role": "user",
        "content": freeText,
      },
    ]);

    final _thread = await _openAI.threads.createThread(request: _request);

    final request = CreateRun(assistantId: assistants.id);
    final response = await _openAI.threads.runs.createRun(threadId: _thread.id, request: request);
    final response2 = await _openAI.threads.runs.retrieveRun(threadId: _thread.id, runId: response.id);
    
    print ('response: ' + response.status);
    await Future.delayed(Duration(seconds: 5));
    print ('response2: ' + response2.status);

Thanks in advance!

@redevrx
Copy link
Owner

redevrx commented May 17, 2024

@Samuramu You want create follow this flow in https://platform.openai.com/docs/assistants/overview

@zhiquan911
Copy link

How can I create a run with stream the response?

@redevrx
Copy link
Owner

redevrx commented Jun 23, 2024

How can I create a run with stream the response?

@zhiquan911 this package yet not support , run with stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants