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
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'],
});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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