You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asynchronous Programming:
Ensure all functions are asynchronous to avoid blocking the main thread.
Cache Results:
Cache frequently accessed data like audience information and chat history to avoid redundant calculations.
Use in-memory caching (e.g., MemoryCache or Redis) for storing repeated data.
3. Optimize API Calls:
For functions making API calls to GPT-4, use parallel requests to reduce wait time.
Use batching for multiple requests or streaming responses for large results.
4. Database Optimization:
For ExtractChatHistory:
Index your database on frequently queried fields (e.g., user_id, timestamp).
Use pagination to fetch only the necessary data instead of the entire history.
5. Pre-process Input Locally:
For GetUserIntentAsync:
Clean and pre-process the input before sending it to GPT-4.
Cache common intents to avoid recalculating for repeated queries.
`public async Task GetUserIntentAsync(string input)
{
// Cache common intents
var cachedIntent = Cache.Get($"intent_{input}");
if (cachedIntent != null) return cachedIntent;
// Use Semantic Kernel or GPT-4 with asynchronous processing
var intent = await GetIntentFromAPIAsync(input);
// Cache result
Cache.Set($"intent_{input}", intent);
return intent;
}
public async Task GetAudienceAsync()
{
// Parallelize API calls if needed
var tasks = new List { Task.Run(() => FetchAudienceData()) };
await Task.WhenAll(tasks);
return tasks[0].Result;
}
`
Describe the bug
The following functions in https://github.com/microsoft/chat-copilot/blob/main/webapi/Plugins/Chat/ChatPlugin.cs take much time
model : GPT-4o in Azure
- GetAudienceAsync = 22965 ms
- ExtractChatHistory= 9623
- GetUserIntentAsync = 10615
To Reproduce
Steps to reproduce the behavior:
Run web API app and ask a question with a context
Expected behavior
Faster response time
Screenshots
If applicable, add screenshots to help explain your problem.
Platform
Additional context
The text was updated successfully, but these errors were encountered: