diff --git a/api/src/controllers/file.js b/api/src/controllers/file.js index b3b09b65..c519993d 100644 --- a/api/src/controllers/file.js +++ b/api/src/controllers/file.js @@ -3,7 +3,7 @@ import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT_KEY, - pinataGateway: "index-network.mypinata.cloud", + pinataGateway: "ipfs.index.network", }); const s3Client = new S3Client({ @@ -29,7 +29,7 @@ export const uploadAvatar = async (req, res, next) => { }); // Upload to IPFS via Pinata - const pinataResult = await pinata.upload.file(file); + const pinataResult = (await pinata.upload.file(file).group(`019335a5-ed91-770d-8f81-db7182c70c2e`)); // Upload to S3 const s3Params = { @@ -44,6 +44,7 @@ export const uploadAvatar = async (req, res, next) => { // Respond with both IPFS CID and S3 URL res.json({ cid: pinataResult.cid, + pinata: `https://ipfs.index.network/files/${pinataResult.cid}`, s3: `https://app-static.index.network/avatars/${pinataResult.cid}.jpg`, }); } catch (error) { diff --git a/api/src/controllers/lit-protocol.js b/api/src/controllers/lit-protocol.js index 8c86aa59..40d7353a 100644 --- a/api/src/controllers/lit-protocol.js +++ b/api/src/controllers/lit-protocol.js @@ -123,7 +123,7 @@ export const getAction = async (req, res, next) => { }); const litAction = await fetch( - `https://ipfs.index.network/ipfs/${cid}?pinataGatewayToken=${process.env.PINATA_IPFS_GATEWAY_KEY}`, + `https://ipfs.index.network/files/${cid}?pinataGatewayToken=${process.env.PINATA_IPFS_GATEWAY_KEY}`, ); let litActionStr = await litAction.text(); litActionStr = `const ACTION_CALL_MODE="read"; ${litActionStr}`; diff --git a/api/src/language/completions.js b/api/src/language/completions.js index 6724c5f4..02b5e6af 100644 --- a/api/src/language/completions.js +++ b/api/src/language/completions.js @@ -3,8 +3,6 @@ import { searchItems } from "./search_item.js"; import { zodResponseFormat } from "openai/helpers/zod"; import { jsonSchemaToZod } from "json-schema-to-zod"; -import { z } from "zod"; - const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, }); @@ -16,9 +14,6 @@ const formatChatHistory = (messages) => { export const handleCompletions = async ({ messages, indexIds, maxDocs=500, stream, schema, timeFilter }) => { - // TODO indexIds is optional because of chat summary. - - // Fetch relevant documents const docs = await searchItems({ indexIds, query: formatChatHistory(messages), @@ -32,13 +27,18 @@ export const handleCompletions = async ({ messages, indexIds, maxDocs=500, strea const retrievedDocs = docs .map(doc => { if (doc.object === "cast") { - return `Cast details: -- text: ${doc.text} -- link: https://warpcast.com/${doc.author.username}/${doc.hash.substring(0, 12)} -- author: [${doc.author.name || doc.author.username}](https://warpcast.com/${doc.author.username}) -- created_at: ${doc.timestamp} - ---- -`; + const authorName = doc.author.name || doc.author.username; + const castUrl = `https://warpcast.com/${doc.author.username}/${doc.hash.substring(0, 12)}`; + const authorUrl = `https://warpcast.com/${doc.author.username}`; + + return [ + 'Cast details:', + `- text: ${doc.text}`, + `- link: ${castUrl}`, + `- author: [${authorName}](${authorUrl})`, + `- created_at: ${doc.timestamp}`, + '----' + ].join('\n'); } return JSON.stringify(doc); }) @@ -53,7 +53,6 @@ export const handleCompletions = async ({ messages, indexIds, maxDocs=500, strea }); } - const completionOptions = { model: process.env.MODEL_CHAT, messages, @@ -61,9 +60,7 @@ export const handleCompletions = async ({ messages, indexIds, maxDocs=500, strea stream: stream, }; - // Add response_format if schema is provided and streaming is disabled if (schema && !stream) { - // Add validation to ensure schema has the expected structure if (!schema.definitions?.response) { throw new Error('Invalid schema format: missing definitions.response'); } diff --git a/api/src/services/did.js b/api/src/services/did.js index a1e5f8b4..7c4d6fc2 100644 --- a/api/src/services/did.js +++ b/api/src/services/did.js @@ -321,7 +321,7 @@ export class DIDService { if (ensProfile.image && ensProfile.image.startsWith(`ipfs://`)) { ensProfile.image = ensProfile.image.replace( `ipfs://`, - `https://ipfs.index.network/ipfs/`, + `https://ipfs.index.network/files/`, ); } return { @@ -341,7 +341,7 @@ export class DIDService { delete profileObj.controllerDID; if (profileObj.avatar) { - profileObj.avatar = `https://ipfs.index.network/ipfs/${profileObj.avatar}`; + profileObj.avatar = `https://ipfs.index.network/files/${profileObj.avatar}`; } return profileObj; diff --git a/web-app/src/config/index.ts b/web-app/src/config/index.ts index 19c38a70..2fc8f29e 100644 --- a/web-app/src/config/index.ts +++ b/web-app/src/config/index.ts @@ -1,5 +1,5 @@ export const appConfig = { - ipfsProxy: "https://ipfs.index.network/ipfs/", + ipfsProxy: "https://ipfs.index.network/files/", chains: { ethereum: { value: "ethereum",