{"id":39997677,"url":"https://github.com/gsilveiradev/star-wars-chatbot-api","last_synced_at":"2026-01-19T01:30:57.069Z","repository":{"id":316810875,"uuid":"1063151437","full_name":"gsilveiradev/star-wars-chatbot-api","owner":"gsilveiradev","description":"Star Wars chatbot made in Python integrated with Claude Sonnet LLM model On AWS Bedrock, using tools for enriched experience","archived":false,"fork":false,"pushed_at":"2025-10-29T16:22:47.000Z","size":17,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-29T18:28:39.117Z","etag":null,"topics":["aws","awsbedrock","bedrock","chatbot","claude","llm","python","starwars","starwars-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gsilveiradev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-24T08:31:53.000Z","updated_at":"2025-10-29T16:22:51.000Z","dependencies_parsed_at":"2025-09-26T22:08:10.247Z","dependency_job_id":"6eb65cfe-5625-43a1-af19-27d9fa95c951","html_url":"https://github.com/gsilveiradev/star-wars-chatbot-api","commit_stats":null,"previous_names":["gsilveiradev/star-wars-chatbot-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gsilveiradev/star-wars-chatbot-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsilveiradev%2Fstar-wars-chatbot-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsilveiradev%2Fstar-wars-chatbot-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsilveiradev%2Fstar-wars-chatbot-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsilveiradev%2Fstar-wars-chatbot-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsilveiradev","download_url":"https://codeload.github.com/gsilveiradev/star-wars-chatbot-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsilveiradev%2Fstar-wars-chatbot-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28556995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T00:46:33.223Z","status":"ssl_error","status_checked_at":"2026-01-19T00:46:32.754Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["aws","awsbedrock","bedrock","chatbot","claude","llm","python","starwars","starwars-api"],"created_at":"2026-01-19T01:30:56.962Z","updated_at":"2026-01-19T01:30:57.059Z","avatar_url":"https://github.com/gsilveiradev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Star Wars chatbot API\n\nThis is a chatbot API that uses [Star Wars public API](https://swapi.dev/) to feed a chatbot integrated with Claude Sonnet 3.5 hosted and runing on a [AWS Bedrock](https://aws.amazon.com/bedrock/).\n\nThe LLM integration uses the Tool Use approach, where the LLM is provided with tools to query external APIs.\n\n- https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview\n- https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-tool-use.html\n\nIn the Star Wars chatbot API, the LLM is provided with the following tools, in the case that model wants to query information about Star Wars universe, specifically about:\n\n- people: https://swapi.dev/api/people/\n- planets: https://swapi.dev/api/planets/\n- films: https://swapi.dev/api/films/\n- species: https://swapi.dev/api/species/\n- vehicles: https://swapi.dev/api/vehicles/\n- starships: https://swapi.dev/api/starships/\n\nSo, if the user asks a question about Star Wars, the model can decide to use one of the tools above to get the information and then answer the user. \n\nFor instance, if the user asks \"Who is Luke Skywalker?\", the model can decide to use the \"people\" tool to get the information about Luke Skywalker and then answer the user.\n\nThis usecase can be applied to many other usecases, where there are APIs already available and the use of an LLM model can enhance the user experience by providing richer and more accurate responses - or even access to data that the model itself doesn't know about.\n\n# Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\nUse [direnv](https://direnv.net/) for local development:\n\n.envrc file example:\n\n```\nexport ENV=development\nexport BEDROCK_AWS_PROFILE=your-aws-profile\nexport BEDROCK_AWS_REGION=us-east-1\nexport BEDROCK_MODEL_ID=anthropic.claude-3-5-sonnet-20240620-v1:0\nexport SW_API_BASE=https://swapi.dev/api/\nexport MAX_TOKENS=1000\n```\n\n```bash\ndirenv allow .\n```\n\n## Login to AWS\n\nSince this API uses AWS Bedrock, you need to login to your AWS account to generate the local environment variables, used by the application to access Bedrock.\n\n- https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html\n\n# Run the app\n\n1) Log in to you AWS account to generate the local environment variables, used by the application to access Bedrock\n\n2) Run the app:\n\n```bash\nuvicorn main:app --reload\n```\n\n## Run via Docker\n\n```bash\ndocker build -t star-wars-chatbot-api .\n```\n\n```bash\ndocker run -it --rm \\\n  -p 8000:8000 \\\n  -v ~/.aws:/root/.aws \\\n  -e ENV=development \\\n  -e BEDROCK_AWS_PROFILE=your-aws-profile \\\n  -e BEDROCK_AWS_REGION=us-east-1 \\\n  -e BEDROCK_MODEL_ID=anthropic.claude-3-5-sonnet-20240620-v1:0 \\\n  -e SW_API_BASE=https://swapi.dev/api/ \\\n  star-wars-chatbot-api\n```\n\n## /suggestions endpoint\n\nThe /suggestions endpoint is a conversation kickoff. It can be used to suggest questions to the user, so the chat starts easily.\n\nWhen asking LLM model to suggest questions, it is provided with some context about Star Wars universe, like people and starships. For other usecases, user/feature personalisation context can be provided so the suggestions are more relevant to the conversation.\n\nSend a POST to http://localhost:8000/suggestions/\n\n```bash\ncurl -N -X POST 'http://localhost:8000/suggestions' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"people\": \"Luke\",\"starships\": \"X-wing\"}'\n```\n\n## /chat endpoint\n\nThe /chat endpoint is the core feature of this API. \n\nIn this iteration, there is no conversation memory, so each question is treated independently. But, each interaction is provided with tools, so LLM model can get more information by requesting our API to give more data about Star Wars universe before reasoning and answering the user.\n\nSend a POST to http://localhost:8000/chat/\n\n```bash\ncurl -N -X POST 'http://localhost:8000/chat' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"user_input\": \"How does the X-wing starfighter compare to other ships in the Star Wars universe?\"}'\n```\n\n## /stream endpoint\n\nThe /stream is the streamed version of /chat endpoint. It uses SSE (server-sent events) to dispatch the LLM model responses.\n\nThis way, the user interaction is expected to be faster and more interative.\n\nSend a POST to http://localhost:8000/stream/\n\n```bash\ncurl -N -X POST 'http://localhost:8000/stream' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"user_input\":\"Who was Luke Skywalker and which starships he piloted? Answer in less than 20 words.\"}'\n```\n\nThe answer will be streamed back as server-sent events. Like this:\n\n```\ndata: {\"delta\": \"Sure, I'd be happy to tell you about Luke Skywalker and his starships! Let me check that information for you.\"}\ndata: {\"tool_event\": {\"used\": true, \"names\": [\"getPeople\", \"getStarships\"]}}\ndata: {\"delta\": \"Luke\"}\ndata: {\"delta\": \" Skywalker\"}\ndata: {\"delta\": \" was a\"}\ndata: {\"delta\": \" Jedi Knight an\"}\ndata: {\"delta\": \"d hero\"}\ndata: {\"delta\": \" of the Rebel\"}\ndata: {\"delta\": \" Alliance.\"}\ndata: {\"delta\": \" He piloted X\"}\ndata: {\"delta\": \"-wings\"}\ndata: {\"delta\": \" an\"}\ndata: {\"delta\": \"d other starships in\"}\ndata: {\"delta\": \" his\"}\ndata: {\"delta\": \" adventures\"}\ndata: {\"delta\": \".\"}\ndata: {\"done\": true}\n```\n\n# Debugging\n\n## Validating AWS Bedrock models\n\nWhen developing this API, it's really important to validate if the provided AWS credentials have access to Bedrock - and to which models. \n\nSo, there is an API endpoint created to validate and debug that. It shows all models that the credentials can access.\n\n1) Log in to you AWS account to generate the local environment variables, used by the application to access Bedrock\n2) Send a GET to http://localhost:8000/debug/bedrock/models","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsilveiradev%2Fstar-wars-chatbot-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsilveiradev%2Fstar-wars-chatbot-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsilveiradev%2Fstar-wars-chatbot-api/lists"}