Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ChatGPT Plugins/OpenAPI specs for Plugins Endpoint #620

Merged
merged 33 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
152e20a
wip: proof of concept for openapi chain
danny-avila Jul 5, 2023
ddfb2ee
chore(api): update langchain dependency to version 0.0.105
danny-avila Jul 9, 2023
a9c8c36
feat(Plugins): use ChatGPT Plugins/OpenAPI specs (first pass)
danny-avila Jul 10, 2023
985553c
chore(manifest.json): update pluginKey for "Browser" tool to "web-bro…
danny-avila Jul 10, 2023
75ae5c8
fix(handleSubmit.js): set unfinished property to false for all endpoints
danny-avila Jul 10, 2023
1d7e33a
fix(handlers.js): remove unnecessary capitalizeWords function and use…
danny-avila Jul 10, 2023
1c7280d
feat(endpoints): add plugins selector to endpoints file
danny-avila Jul 10, 2023
0b9aedf
fix(OpenAPIPlugin.js): rename readYamlFile function to readSpecFile
danny-avila Jul 10, 2023
7dd27f9
feat(api): add new tools
danny-avila Jul 11, 2023
4bacbfa
feat(PluginsClient.js): import findMessageContent function from utils
danny-avila Jul 11, 2023
9b869d4
fix(PluginStoreDialog.tsx): update z-index value for the dialog conta…
danny-avila Jul 11, 2023
04238b0
chore(web_pilot.json): add "params" field with "user_has_request" par…
danny-avila Jul 11, 2023
44d2728
chore(eslintrc.js): update eslint rules
danny-avila Jul 12, 2023
d6fa947
fix(package-lock.json): update langchain dependency to version ^0.0.105
danny-avila Jul 12, 2023
a694305
fix(OpenAPIPlugin.js): change header key from 'id' to 'librechat_user…
danny-avila Jul 12, 2023
4af56a1
fix(OpenAPIPlugin.js): update SUFFIX variable to provide a clearer de…
danny-avila Jul 12, 2023
2289b84
feat(PluginsClient.js): sendIntermediateMessage on successful Agent load
danny-avila Jul 12, 2023
425f306
Update chatgpt_plugins_openapi.md
danny-avila Jul 13, 2023
2dc4220
chore: rebuild package-lock file
danny-avila Jul 14, 2023
ab9a88d
chore: format/lint all files with new rules
danny-avila Jul 14, 2023
c981102
chore: format all files
danny-avila Jul 14, 2023
0bc6f71
chore(README.md): update AI model selection list
danny-avila Jul 14, 2023
5863f08
fix(Plugin.tsx): type issue
danny-avila Jul 14, 2023
e3e9f07
feat(tools): add new tool WebPilot
danny-avila Jul 14, 2023
33f6aab
feat(OpenAPIPlugin.js): add getSpec and readSpecFile functions
danny-avila Jul 14, 2023
6772438
chore(agent-demo-1.js): remove unused code and dependencies
danny-avila Jul 14, 2023
65824d4
feat(addOpenAPISpecs): add function to transform OpenAPI specs into d…
danny-avila Jul 14, 2023
4722289
feat(loadSpecs.spec.js): add unit tests for ManifestDefinition, valid…
danny-avila Jul 14, 2023
2ba240e
fix: package file resolution bug
danny-avila Jul 14, 2023
1ae0348
chore: move scholarly_graph_link manifest to 'has-issues'
danny-avila Jul 14, 2023
f67ae4a
refactor(client/hooks): convert to TS and export from index
danny-avila Jul 15, 2023
dbcc3ef
Update introduction.md
danny-avila Jul 15, 2023
1b552be
Update chatgpt_plugins_openapi.md
danny-avila Jul 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(OpenAPIPlugin.js): add getSpec and readSpecFile functions
feat(OpenAPIPlugin.spec.js): add tests for readSpecFile, getSpec, and createOpenAPIPlugin functions
  • Loading branch information
danny-avila committed Jul 15, 2023
commit 33f6aabea97537fcae9bd30bd369bb9df3bce954
2 changes: 2 additions & 0 deletions api/app/clients/tools/dynamic/OpenAPIPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,7 @@ async function createOpenAPIPlugin({ data, llm, user, message, verbose = false }
}

module.exports = {
getSpec,
readSpecFile,
createOpenAPIPlugin,
};
65 changes: 65 additions & 0 deletions api/app/clients/tools/dynamic/OpenAPIPlugin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const fs = require('fs');
const { createOpenAPIPlugin, getSpec, readSpecFile } = require('./OpenAPIPlugin');

jest.mock('node-fetch');
jest.mock('fs', () => ({
promises: {
readFile: jest.fn(),
},
existsSync: jest.fn(),
}));

describe('readSpecFile', () => {
it('reads JSON file correctly', async () => {
fs.promises.readFile.mockResolvedValue(JSON.stringify({ test: 'value' }));
const result = await readSpecFile('test.json');
expect(result).toEqual({ test: 'value' });
});

it('reads YAML file correctly', async () => {
fs.promises.readFile.mockResolvedValue('test: value');
const result = await readSpecFile('test.yaml');
expect(result).toEqual({ test: 'value' });
});

it('handles error correctly', async () => {
fs.promises.readFile.mockRejectedValue(new Error('test error'));
const result = await readSpecFile('test.json');
expect(result).toBe(false);
});
});

describe('getSpec', () => {
it('fetches spec from url correctly', async () => {
const parsedJson = await getSpec('https://www.instacart.com/.well-known/ai-plugin.json');
const isObject = typeof parsedJson === 'object';
expect(isObject).toEqual(true);
});

it('reads spec from file correctly', async () => {
fs.existsSync.mockReturnValue(true);
fs.promises.readFile.mockResolvedValue(JSON.stringify({ test: 'value' }));
const result = await getSpec('test.json');
expect(result).toEqual({ test: 'value' });
});

it('returns false when file does not exist', async () => {
fs.existsSync.mockReturnValue(false);
const result = await getSpec('test.json');
expect(result).toBe(false);
});
});

describe('createOpenAPIPlugin', () => {
it('returns null when getSpec throws an error', async () => {
const result = await createOpenAPIPlugin({ data: { api: { url: 'invalid' } } });
expect(result).toBe(null);
});

it('returns null when no spec is found', async () => {
const result = await createOpenAPIPlugin({});
expect(result).toBe(null);
});

// Add more tests here for different scenarios
});