Replies: 1 comment
-
|
This discussion was automatically locked because it has not been updated in over 30 days. If you still have questions about this topic, please ask us at community.vercel.com/ai-sdk |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I modified the Angular example to interface with Azure OpenAI model. However, I can only get general conversation responses, if I try to force it to do a tool call (e.g., "Get the weather in DC" ), it returns empty. Am I doing something wrong here?
`import { createAzure } from '@ai-sdk/azure';
import { convertToModelMessages, streamObject, streamText, tool } from 'ai';
import 'dotenv/config';
import express, { Request, Response } from 'express';
import z from 'zod';
import { experimental_createMCPClient as createMCPClient } from 'ai';
import { Experimental_StdioMCPTransport as StdioMCPTransport } from 'ai/mcp-stdio';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp';
async function startServer() {
const azure = createAzure({
resourceName: 'ai-sdk-test', // extracted from your endpoint
apiKey: process.env['AZURE_OPENAI_API_KEY'],
});
const app = express();
app.use(express.json({ strict: false })); // Allow primitives (for analyze endpoint)
app.post('/api/chat', async (req: Request, res: Response) => {
const { messages, selectedModel } = req.body;
const result = streamText({
model: azure(selectedModel || 'gpt-4.1'), // Use your deployment name
messages: convertToModelMessages(messages),
tools: allTools,
});
});
app.post('/api/completion', async (req: Request, res: Response) => {
try {
const { prompt } = req.body;
console.log('Received completion request:', { prompt });
});
app.post('/api/analyze', express.raw(), async (req: Request, res: Response) => {
const input = req.body.toString('utf8');
});
app.listen(3000, () => {
console.log(
Example app listening on port ${3000});});
}
// Start the server
startServer().catch(console.error);
`
Beta Was this translation helpful? Give feedback.
All reactions