{"id":18916927,"url":"https://github.com/chainlit/literalai-typescript","last_synced_at":"2025-04-15T09:31:23.172Z","repository":{"id":251769874,"uuid":"731990041","full_name":"Chainlit/literalai-typescript","owner":"Chainlit","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-07T13:27:38.000Z","size":390,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-07T13:50:10.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.literalai.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chainlit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-15T11:12:55.000Z","updated_at":"2024-11-07T13:27:27.000Z","dependencies_parsed_at":"2024-11-07T13:38:55.374Z","dependency_job_id":"ef1eb2b8-9b59-417c-ba89-c10995e16221","html_url":"https://github.com/Chainlit/literalai-typescript","commit_stats":null,"previous_names":["chainlit/literalai-typescript"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chainlit%2Fliteralai-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chainlit%2Fliteralai-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chainlit%2Fliteralai-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chainlit%2Fliteralai-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chainlit","download_url":"https://codeload.github.com/Chainlit/literalai-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223665667,"owners_count":17182353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T10:22:46.043Z","updated_at":"2024-11-08T10:22:46.667Z","avatar_url":"https://github.com/Chainlit.png","language":"TypeScript","readme":"# Literal AI Node API Library\n\nThis library provides convenient access to the Literal GraphQL API and other utilities.\n\n## Installation\n\n```shell\nnpm i @literalai/client\n```\n\n## Get an API key\n\nTo get an API key, go to the [Literal AI](https://cloud.getliteral.ai), create an account and copy your API key from the settings page.\n\n## Usage\n\nThe full documentation of the SDK can be found [here](https://docs.getliteral.ai/typescript-client/introduction).\n\nYou can also find more involved examples in our [cookbooks repository](https://github.com/Chainlit/literal-cookbook).\n\n### Basic usage\n\nThe following example will create a Thread on Literal AI and create a Step inside this Thread.\n\n```typescript\nimport { LiteralClient } from '@literalai/client';\n\nconst client = new LiteralClient();\n\nawait client.thread({ name: 'Test Wrappers Thread' }).wrap(async () =\u003e {\n  // You can access the current thread and step using the client\n  const thread = client.getCurrentThread();\n\n  // This step will be created with the thread as its parent\n  await client\n    .step({ name: 'Test Wrappers Step', type: 'assistant_message' })\n    .send();\n});\n```\n\n### Advanced usage\n\nThe following example will create a Thread with a Run step nested inside. In the Run step, we will create two child steps: one for a retrieval and another for an LLM completion.\n\n```typescript\nimport { LiteralClient } from '@literalai/client';\n\nconst client = new LiteralClient();\n\n// Wrapped functions can be defined anywhere\n// When they run, they will inherit the current thread and step from the context\nconst retrieve = async (_query: string) =\u003e\n  client.step({ name: 'Retrieve', type: 'retrieval' }).wrap(async () =\u003e {\n    // Fetch data from the vector database ...\n\n    return [\n      { score: 0.8, text: 'France is a country in Europe' },\n      { score: 0.7, text: 'Paris is the capital of France' }\n    ]\n  });\n\nconst completion = async (_query: string, _augmentations: string[]) =\u003e\n  client.step({ name: 'Completion', type: 'llm' }).wrap(async () =\u003e {\n    // Fetch completions from the language model ...\n    return { content: 'Paris is a city in Europe' };\n  });\n\n  // The output of wrapped functions will always bubble up the wrapper chain\n  const result = await client\n    .thread({ name: 'Test Wrappers Thread' })\n    .wrap(async () =\u003e {\n      return client.run({ name: 'Test Wrappers Run' }).wrap(async () =\u003e {\n        const results = await retrieve(query);\n        const augmentations = results.map((result) =\u003e result.text);\n        const completionText = await completion(query, augmentations);\n        return completionText.content;\n      });\n    });\n\n  return result;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainlit%2Fliteralai-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainlit%2Fliteralai-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainlit%2Fliteralai-typescript/lists"}