Not getting the response back
Unanswered
Turkish Angora posted this in #help-forum
Turkish AngoraOP
this is my route.ts file inside chat folder of the api folder
import { StreamingTextResponse, CohereStream } from 'ai'
// IMPORTANT! Set the runtime to edge
export const runtime = 'edge'
export async function POST(req: Request) {
// Extract the `prompt` from the body of the request
const { prompt } = await req.json()
const body = JSON.stringify({
prompt,
model: 'command-nightly',
max_tokens: 300,
stop_sequences: [],
temperature: 0.9,
return_likelihoods: 'NONE',
stream: true
})
const response = await fetch('https://api.cohere.ai/v1/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.COHERE_API_KEY}`
},
body
})
// Extract the text response from the Cohere stream
const stream = CohereStream(response)
// Respond with the stream
return new StreamingTextResponse(stream)
} this is my folder structure └── 📁src
└── 📁app
└── 📁api
└── 📁chat
└── route.ts
└── 📁create-chat
└── route.ts
└── 📁get-messages
└── route.ts
└── 📁chat
└── 📁[chatId]
└── page.tsx
└── favicon.ico
└── globals.css
└── layout.tsx
└── page.tsx
└── 📁sign-in
└── 📁[[...sign-in]]
└── page.tsx
└── 📁sign-up
└── 📁[[...sign-up]]
└── page.tsx
└── 📁components
└── ChatComponent.tsx
└── ChatSideBar.tsx
└── FileUpload.tsx
└── MessageList.tsx
└── PDFViewer.tsx
└── Provider.tsx
└── 📁ui
└── button.tsx
└── input.tsx
└── 📁lib
└── 📁db
└── index.ts
└── schema.ts
└── embeddings.ts
└── pinecone.ts
└── s3-server.ts
└── s3.ts
└── utils.ts
└── middleware.ts please help