<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ransaka Ravihara on Medium]]></title>
        <description><![CDATA[Stories by Ransaka Ravihara on Medium]]></description>
        <link>https://medium.com/@ransakaravihara?source=rss-61b4d96de932------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-fYonXazRWUC-QtGdOHENA.jpeg</url>
            <title>Stories by Ransaka Ravihara on Medium</title>
            <link>https://medium.com/@ransakaravihara?source=rss-61b4d96de932------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 20:55:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ransakaravihara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Multi-Agent Application to Interact with Google Products]]></title>
            <link>https://medium.com/google-cloud/building-a-multi-agent-application-to-interact-with-google-products-b7ff7eb2f17d?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7ff7eb2f17d</guid>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[agent-development-kit]]></category>
            <category><![CDATA[gcp-app-dev]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[agentic-applications]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 23:48:51 GMT</pubDate>
            <atom:updated>2025-04-22T23:48:51.664Z</atom:updated>
            <content:encoded><![CDATA[<h4>In this article, I will provide a step-by-step introduction to Google’s brand-new multi-agent orchestration framework, Google ADK, and explain how to use ADK to build multi-agent systems.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izXn-M1w20c1ZgafkrMNOQ.png" /><figcaption>The workflow that we are building</figcaption></figure><p>First of all, there are a few prerequisites for this project. We will need a Google Client ID and Client Secret, as we need to authorize users via OAuth.</p><h3>Prerequisites</h3><blockquote>Creating google client id and client secret.</blockquote><p>Head to the Google Cloud Console, select <strong><em>APIs &amp; Services</em></strong>, and then go to <strong><em>Credentials</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VKmozg91SWXEnqSqADXaRw.png" /></figure><p>Once you are there, you can create an OAuth 2.0 client by following the on-screen instructions. However, before doing so, you will need to set up the OAuth consent screen. There, you will need to fill in basic fields, which are straightforward. Alright, let’s begin with creating our OAuth client keys.</p><h4>Step 1</h4><p>Click the <strong><em>Create Credentials</em></strong> button, then in the application type dropdown, select the <strong><em>Web Application</em></strong> option. Give it a meaningful name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZf7j6BOyeWERgoiFJb0cA.png" /><figcaption>Step 1: Creating an OAuth client</figcaption></figure><p><strong>Step 2</strong></p><p>Click <em>Add URI</em> under <strong><em>Authorized Redirect URIs</em></strong>. This is where you redirect users after they successfully authorize. Since this is a demo application, you can set this as your local endpoint. I set mine as <a href="http://localhost:8000/callback">http://localhost:8000/callback</a>.</p><p>Perfect, that’s all. Now you are ready for the next step. Before proceeding, note down the Client ID, Client Secret, and Redirect URI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTVnitiYu8PcTxIc4bfQQQ.png" /><figcaption>Add the redirect URI and save the client details</figcaption></figure><h3>Building Agents</h3><p>Okay, now it’s time to orchestrate these agents to achieve the idea we are building. As a quick refresher, this is the idea we have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qOwz1dMby8IqiQyrsDKVA.png" /><figcaption>It’s really simple but ideal for getting started and exploring.</figcaption></figure><p>First things first, you will need to install the Google Agent Development Kit beforehand. Follow <a href="https://google.github.io/adk-docs/get-started/quickstart/"><em>these steps</em></a> to install it. I recommend installing it in a separate environment to avoid version conflicts.</p><h4>Understanding Google’s ADK Agent Categories</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RqyUTaR9l2xARcG8.png" /><figcaption>Image credit: <a href="https://google.github.io/adk-docs/agents/#agents">google-adk-documentation</a></figcaption></figure><p>The Agent Development Kit offers flexibility to choose agents based on our requirements. Each agent has its reasons for being selected. Here, I will choose an LLM-based agent for my task. It allows flexibility to select available sub-agents for task delegation based on user queries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CrBBYQB0PG9k02ARvtoWsg.png" /><figcaption>Our root agent</figcaption></figure><pre>from google.adk.agents import LlmAgent<br><br>router_agent = LlmAgent(<br>    model=MODEL_NAME,<br>    name=&quot;task_router_agent&quot;,<br>    description=&quot;Acts as the main interface, routing tasks to Gmail or Calendar agents or answering general questions.&quot;,<br>    instruction=&quot;&quot;&quot;Understand the user&#39;s request.<br>                - If the request relates to Gmail (reading/sending email, user profile), delegate the task to the &#39;google_gmail_agent&#39;.<br>                - If the request relates to Google Calendar (listing/creating events), delegate the task to the &#39;google_calendar_agent&#39;.<br>                - If the user asks a general question not related to Gmail or Calendar tools, answer it using your own knowledge.<br>                - If you are unsure which agent to use or the request is ambiguous, ask the user for clarification.<br>                - If a sub-agent reports an error, relay the exact error message to the user.&quot;&quot;&quot;, # debugging purposes<br>    sub_agents=[...]<br>)</pre><p>Alright, it’s clear and straightforward. However, notice the sub_agent argument we provided for the LlmAgent class. This is where we tell them about the available agents for task delegation. Next, we can start building sub-agents.</p><h4>Building Sub Agents</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H1rtVg0AdQfcLrc9qFOQBg.png" /><figcaption>Workflow, up to sub-agents</figcaption></figure><p>Perfect, now it’s time to code our agents. It’s no different from our root_agent.</p><pre>gmail_agent = LlmAgent(<br>    model=MODEL_NAME,<br>    name=&quot;google_gmail_agent&quot;,<br>    description=&quot;Handles Gmail tasks like reading emails, sending emails, and checking user profiles.&quot;,<br>    instruction=&quot;You handle queries related to Gmail. Do not ask any followup questions related to user ids, gmail ids etc. The special string `me` is used to refer to the authenticated user. You don&#39;t need to know the actual email address or user ID if you&#39;re making requests on behalf of the logged-in user. Use the available tools to fulfill the user&#39;s request. If you encounter an error, provide the *exact* error message so the user can debug.&quot;,<br>    tools=gmail_tools<br>)<br><br>calendar_agent = LlmAgent(<br>    model=MODEL_NAME,<br>    name=&quot;google_calendar_agent&quot;,<br>    description=&quot;Handles Calendar tasks like listing events, creating events, and getting event details.&quot;,<br>    instruction=&quot;You handle queries related to Google Calendar. Never ask user to provide the calendarId, users&#39;s main Google Calendar ID is usually just &#39;primary&#39;. Use the available tools to fulfill the user&#39;s request. If you encounter an error, provide the *exact* error message so the user can debug.&quot;,<br>    tools=calendar_tools<br>)</pre><p>There is an additional input called tools. These are the usual tools we provide to agents to enhance their capabilities. However, things are different here. To access Google product details like Calendar and Gmail, we need the user&#39;s consent, also known as authorization. Only then can these tools function. In this tutorial, I&#39;m going to use the OAuth authorization protocol that Google offers, but you can use different authorization methods depending on the application you&#39;re integrating.</p><p>In this step, I assume you have the Google client ID, client secret, and redirect URI set up in the prerequisite section.</p><h4>Authorization and Defining Tools</h4><p>Google’s ADK offers very convenient building blocks to handle the authorization process smoothly. All we need to do is define the tools, their specifications, and authorization details.</p><p>For the tools’ API specification, you can follow these steps. The purpose of the API specification is to give the LLM an understanding of how these tools should be used, which parameters to include, and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ar2cGprBcV1Cv3t7mUYHQ.png" /><figcaption>Example OpenAPI spec. for Calendar</figcaption></figure><p>Generating an <a href="https://en.wikipedia.org/wiki/OpenAPI_Specification">OpenAPI specification</a> from the <a href="https://cloud.google.com/docs/discovery">Google Discovery API</a> is relatively easy. I found the following tool more convenient. All you have to do is find the relevant Google Discovery API for your product of interest, head over to <a href="https://lucybot-inc.github.io/api-spec-converter/">https://lucybot-inc.github.io/api-spec-converter/</a>, select the source and destination formats, and download the results. Nevertheless, all API specifications related to this task are available in my <a href="https://github.com/Ransaka/google-service-agent/tree/main"><em>GitHub repository</em></a>. Great! Now we can define the tools for sub-agents.</p><pre>from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_toolset import OpenAPIToolset<br>from fastapi.openapi.models import OAuth2, OAuthFlowAuthorizationCode, OAuthFlows<br>from google.adk.auth import AuthConfig, AuthCredential, AuthCredentialTypes, OAuth2Auth<br><br>required_scopes = {<br>    &quot;https://www.googleapis.com/auth/gmail.readonly&quot;: &quot;gmail read scope&quot;,<br>    &quot;https://www.googleapis.com/auth/gmail.send&quot;: &quot;gmail send scope&quot;,<br>    &quot;https://www.googleapis.com/auth/userinfo.profile&quot;: &quot;user profile scope&quot;,<br>    &quot;https://www.googleapis.com/auth/calendar.events&quot;: &quot;calendar read/write events scope&quot;,<br>    &quot;https://www.googleapis.com/auth/calendar.calendarlist&quot;: &quot;calendar read scope&quot;<br>}<br><br>auth_scheme = OAuth2(<br>   flows=OAuthFlows(<br>      authorizationCode=OAuthFlowAuthorizationCode(<br>            authorizationUrl=&quot;https://accounts.google.com/o/oauth2/auth&quot;,<br>            tokenUrl=&quot;https://oauth2.googleapis.com/token&quot;,<br>            scopes=required_scopes,<br>      )<br>   )<br>)<br>auth_credential = AuthCredential(<br>   auth_type=AuthCredentialTypes.OAUTH2,<br>   oauth2=OAuth2Auth(<br>      client_id=client_id,<br>      client_secret=client_secret<br>   ),<br>)<br><br>with open(&quot;api_specs/open_api_gmail_spec.txt&quot;, &quot;r&quot;) as f: <br>    gmail_spec_str = f.read()<br>gmail_api_toolset = OpenAPIToolset(<br>   spec_str=gmail_spec_str,<br>   spec_str_type=&#39;yaml&#39;, <br>   auth_scheme=auth_scheme, auth_credential=auth_credential,<br>)<br>gmail_selected_tool_names = [<br>    &#39;gmail_users_messages_list&#39;, &#39;gmail_users_messages_get&#39;,<br>    &#39;gmail_users_messages_send&#39;, &#39;gmail_users_get_profile&#39;<br>]<br>all_gmail_tool_names = {tool.name for tool in gmail_api_toolset.get_tools()}<br>gmail_tools = [tool for tool in gmail_api_toolset.get_tools() if tool.name in gmail_selected_tool_names]<br><br><br>with open(&quot;api_specs/open_api_calendar_spec.txt&quot;, &quot;r&quot;) as f:<br>    calendar_spec_str = f.read()<br>calendar_api_toolset = OpenAPIToolset(<br>   spec_str=calendar_spec_str,<br>   spec_str_type=&#39;yaml&#39;, <br>   auth_scheme=auth_scheme, auth_credential=auth_credential,<br>)<br>calendar_selected_tool_names = [<br>    &#39;calendar_events_list&#39;, &#39;calendar_events_insert&#39;, &#39;calendar_events_get&#39;, &#39;calendar_calendar_list_list&#39;<br>]<br>all_calendar_tool_names = {tool.name for tool in calendar_api_toolset.get_tools()}<br>calendar_tools = [tool for tool in calendar_api_toolset.get_tools() if tool.name in calendar_selected_tool_names]</pre><p>Now we have all the components related to tool use and authorization. It’s time to wrap the Agent with a chat interface for the demo. First, let’s revisit the workflow so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQjjYCnY0GrQsERB9AsntA.png" /><figcaption>Agents check for user consent and use tools.</figcaption></figure><p>Now it’s time to test the application.</p><h3>Agent in Action</h3><p>The simplest way to test ADK applications is by using the command adk web. This will open a web server on your local machine, allowing you to send messages, check the agent’s internal states, and understand agent handoffs. However, I will continue this testing using the command-line version. Okay, let’s start chatting!</p><p>Starting with a general question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NjM-6nX0YhSHyMZx3Thj7g.png" /><figcaption>Asking a general question</figcaption></figure><p>Looks good! Now, let’s try a query related to a Google product, such as listing calendar events..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hc9K06FEqU8YQL_qOZNgSQ.png" /><figcaption>Asking the agent to list upcoming events.</figcaption></figure><p>Since this is the very beginning of our conversation, the application triggered the authorization flow. This will ask the user to copy the URL populated in the interface and open it in a browser. This will redirect the user to a typical Google authorization page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yj6f4l-3Am3ZndFgJOHcqw.png" /><figcaption>Typical Google authorization page</figcaption></figure><p>Once you click <em>Allow</em>, this will navigate you to the redirect URI you specified during the OAuth client setup. Once you have successfully authenticated, it will respond to your queries promptly, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agTp3qfe-NvBD8NE4T5EuA.png" /><figcaption>Agent responds after authentication.</figcaption></figure><p>Great, now we have completed our agent setup. This agent will be able to read emails for you, summarize them, send them to a given address, and schedule events based on email content. However, doing all of these in a single prompt is currently not feasible, but it’s doable with minimal code changes. Code for this project can be accessed <a href="https://github.com/Ransaka/google-service-agent/tree/main">here</a>.</p><h3>Conclusion</h3><p>This concludes the defined task of building a multi-agent system interacting with Google products. Based on my experiment, the Google ADK framework contains powerful agent orchestration tools and, most importantly, a massive ecosystem on GCP. For example, Google recently launched the Agent Garden, focusing on building multi-agent systems on top of Google products. This is a significant step toward organizations that need to adopt agent/multi-agent systems but hesitate due to privacy and security concerns. There’s still a long way to go, but I believe this project will inspire you to build even more amazing projects.</p><p>Thank you so much for reading! Have feedback? Connect with me via <a href="https://www.linkedin.com/in/ransaka/?_l=en_US">LinkedIn</a>.</p><p><strong>**</strong><em>All images, unless otherwise noted, are by the author**</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7ff7eb2f17d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/building-a-multi-agent-application-to-interact-with-google-products-b7ff7eb2f17d">Building a Multi-Agent Application to Interact with Google Products</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building LLM-Powered Coding Assitant for GitHub: RAG with Gemini and Redis]]></title>
            <link>https://medium.com/data-science/building-llm-powered-coding-assitant-for-github-rag-with-gemini-and-redis-b88beeb42f2d?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/b88beeb42f2d</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 10:38:36 GMT</pubDate>
            <atom:updated>2025-04-24T14:21:42.797Z</atom:updated>
            <content:encoded><![CDATA[<h4>How I build a GitHub repository assistant capable of answering user issues</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0j5BbwyMs3i55o3o200Rw.png" /><figcaption>A nerd who loves to explore and assist people. (Generated using <a href="https://www.canva.com/ai-image-generator/">Canva</a>)</figcaption></figure><h3>Introduction</h3><p>Since you are reading this article, you are likely into data science, machine learning, or AI; Ultimately, you are up to programming. Programmers more often experience bugs, issues, and errors. That’s where things are getting serious, especially when working on a relatively new framework or library. At that moment, I always consider the benefits of having an intelligent assistant who possesses knowledge of various subjects and can effectively provide instruction. Once tasked, my assistant could go through the entire code repository, scan each line of code, and remember all logic for quick fixes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TsBbn2HQQzUNwzGJuoue6g.jpeg" /><figcaption>Image by Author via <a href="https://www.canva.com/ai-image-generator/">Canva</a></figcaption></figure><p>That sounds quite fancy, right? Creating such a system used to seem like something out of science fiction, but it’s achievable these days, requiring only a few well-focused evenings.</p><p>Let’s gear up and do some coding to achieve our task. As I described above, our assistant has the following functionalities:</p><ul><li>Read the entire code base and store it.</li><li>Understand each member’s use within the code base (Map class/function dependencies).</li><li>Pull up all the <strong>required</strong> codes when the user asks a question and provide concise instructions to solve the issue.</li></ul><h3>Read the entire code base and store it.</h3><p>We must provide a related code base to give our agent context. But the way it stores is a matter. Storing additional metadata such as docstring and function/class level dependencies will add value to the data. Because the more data we have, the more intelligent our agents become. One aspect I am concerned about here is not picking only the most relevant code pieces. But also dependent code pieces. For example, the user may have an issue with a <em>Tokenizer </em>class<em>. </em>Still<em>, </em>we aren’t fully confident the required fix can be given only by inspecting <em>Tokenizer</em> because each class/function uses the others interchangeably. That’s why we need to understand those dependencies when building such systems.</p><p>Let’s break down the steps we might need to achieve this.</p><ul><li>Clone the GitHub repository.</li><li>Read each .py file it has and store details in memory.</li><li>Derive function/class usage and map dependencies between them.</li></ul><p>This sounds straightforward, but when we recall our end goal, we can see that a few pieces are missing.</p><p>Yet, we have not thought about a way to pull up necessary code pieces for user questions. The solution is combining information retrieval with vector search. But there is a catch. In most cases, we can use appropriate text columns for vector search functionality. Here, the situation is different as we are dealing with codebase. Therefore, I decided to try a few options and pick the one with decent performance. The selected workaround for this issue is,</p><ol><li>First, generate a description for each code piece using LLM.</li><li>Then, create a new field combining code definition and LLM-generated code description. (You may obtain a Gemini API key for this)</li><li>Calculate vector embeddings for newly created columns and store them in the database.</li></ol><p>At the end of these steps, our data structure will be something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b498c9b5b51a3ad683f08a5f04216d6d/href">https://medium.com/media/b498c9b5b51a3ad683f08a5f04216d6d/href</a></iframe><p>At this point, we have to finalize the vector database we have to use. We can use vector databases like Faiss, Milvus, or any other. But this time, I decided to go ahead with the database I never used. I intended to explore something new and add that to my day-to-day toolbox. So, I ended up choosing <a href="https://redis.io/kb/doc/28x16buszr/can-i-use-redis-as-a-vector-database#:~:text=Answer,Redis%20as%20a%20Vector%20Database.">Redis</a>. If you continue with Redis, follow <a href="https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/">these instructions</a> to set up a Redis instance on your local machine. If you prefer a simple solution, sign up for a Redis free account and create a database by following the instructions listed on their <a href="https://redis.io/docs/latest/operate/oss_and_stack/install/">website</a>. Nevertheless, all you want for this step is a Redis host, port, and password.</p><p>We’re all set to take our first step. To help us understand, let’s visualize what we’ve described so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kOV9iAgNnZAaSh_TWn-tg.png" /><figcaption>Data Ingestion Pipeline</figcaption></figure><p>Let’s see how we can build this. As a first step, we need to convert the given GitHub repository into a knowledge graph. When searching for a suitable library for this purpose, I found a few overcomplicated (For my use case) solutions. Therefore, I planned to build a more straightforward library for this use case. You can install it using pip install sourcegraph. You can check the repository using the link below.</p><p><a href="https://github.com/Ransaka/sourcegraph">GitHub - Ransaka/sourcegraph</a></p><p>This Python library allows you to convert a given Python GitHub repository into a NetworkX graph. Its use is simple and requires only a few steps.</p><p>Let’s jump into the coding part.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99f8031a49b2702b081e260d009bdc31/href">https://medium.com/media/99f8031a49b2702b081e260d009bdc31/href</a></iframe><p>After executing the above step, we have obtained a dataset with the below schema.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/392654a4e7ff1662e6f04a5c71f30621/href">https://medium.com/media/392654a4e7ff1662e6f04a5c71f30621/href</a></iframe><p>In the above code snippet, we did a bunch of things.</p><ol><li>We fetch the GitHub repository data.</li><li>Generate descriptions for each code piece.</li><li>Mapped each function’s dependencies and stored them as JSON objects.</li></ol><p>Okay, our next goal is to build a pipeline to,</p><ul><li>Store these data in the database</li><li>Retrieve data relevant to user queries.</li></ul><p>Let’s dive into that. First, we must implement a step to store data in the database. After that, we can add an embedding field to the records. Finally, we need to add indexes to search for elements from the database. One of the searchable fields should be the embedding field we have planned above. As with other vector searches, we must specify the indexing algorithm here. Since we are dealing with a relatively small dataset, I am picking the indexing method as <em>FLAT</em> here in vector search.</p><p>Let’s replicate the same with codes quickly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/681cd1ba6c5bbe6e5893c78b6c3cbbb5/href">https://medium.com/media/681cd1ba6c5bbe6e5893c78b6c3cbbb5/href</a></iframe><p>Let’s check out the sample data beforehand. It will ensure that everything is as expected and that we are good to go with the rest of the processes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99f0949691e8d4b266eb6ab99666c1aa/href">https://medium.com/media/99f0949691e8d4b266eb6ab99666c1aa/href</a></iframe><p>Everything is going as planned; we’re in a safe area. Let’s proceed.</p><p>Our next objective should be to build a mechanism to retrieve relevant documents based on the given issues. In other words, we have to implement vector search capability there. Let’s add that piece of code as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd05469b97395aea7a197e576188cc08/href">https://medium.com/media/bd05469b97395aea7a197e576188cc08/href</a></iframe><p>In the code above, we first calculate text embeddings for a given user query. Then, we perform a KNN search over the elements in the database. In KNN, you could also define a search range. You can accomplish that using the code below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea47f4fe4ee0acce4de1b2472ee85013/href">https://medium.com/media/ea47f4fe4ee0acce4de1b2472ee85013/href</a></iframe><p>Note the score attribute in each document we retrieved. It represents the distance to the provided query. The lower the distance, the more relevant the documents are. With that step, we completed the first component of our coding assistant.</p><h3>Building Retrieval Pipeline and Integrate with LLM</h3><p>In this step, we must combine a previously built data store with a large language model. The ideal workflow can then be split into two steps.</p><ol><li>The user asks questions; the retrieval pipeline retrieves related code snippets and draft prompts to feed LLM.</li><li>Based on prompts, LLM generates responses. The application front end sends these responses back to the user.</li></ol><p>For better clarity, let’s visualize the steps we discussed earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AOvS0l9WBsPVjikSbhavrw.png" /><figcaption>The user asks a question, and then the retrieval pipeline fetches the required data and sends it to the application. The application compiles the codes, drafts a prompt, and sends it back to LLM. Afterward, the LLM response is delivered to the user.</figcaption></figure><p>That’s quite a lot of work. First, we must find a suitable LLM orchestration framework, so I am picking Haystack <a href="https://medium.com/towards-data-science/using-llama-3-for-building-ai-agents-7e74f79d1ccc">this time</a>, too.</p><p>I am expanding our previous vector search function to meet the requirements described above first point.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbfa31eed0597324eaf1574ef331119a/href">https://medium.com/media/cbfa31eed0597324eaf1574ef331119a/href</a></iframe><p>Okay, let’s try out what we have just built.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36205a1b1358a9233648ed5a89a0cfec/href">https://medium.com/media/36205a1b1358a9233648ed5a89a0cfec/href</a></iframe><p>The next step is to provide this prompt to LLM and get a response from LLM. Let’s use the Haystack framework to streamline this process. One of the tricky points here is to convert the above <em>draft_prompt</em> function into the Haystak component. Let’s see how we can implement that.</p><h3>Building a retriever component and prompt template</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69e701f33cb58f16de1b7ebd3431af67/href">https://medium.com/media/69e701f33cb58f16de1b7ebd3431af67/href</a></iframe><p>Perfect, now we have all the necessary components to finish our code assistant. Let’s define the steps and connections we require to connect these processes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8f6a1d412d8886d8714e16b3a1079f5/href">https://medium.com/media/d8f6a1d412d8886d8714e16b3a1079f5/href</a></iframe><p>Here’s the pipeline formation to ensure everything aligns with our intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*rIZqT7gIcnoac3TmwrRA_w.png" /><figcaption>Haystack Pipeline</figcaption></figure><p>Now, we have a fully functional pipeline to handle user issues related to the target codebase. Let’s try asking a simple question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-ARKdIKEsk8ch5xFCooxw.png" /><figcaption>Response to Sample User Question</figcaption></figure><p>It worked as expected. Let’s wrap this up as a streamlit application as a final step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c55f3af75ae913052db388130039b31/href">https://medium.com/media/7c55f3af75ae913052db388130039b31/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFoNmKF7oIoqTmOoJAwaHg.png" /><figcaption>Our Assitant UI</figcaption></figure><p>I have hosted this code repository in a HuggingFace space so that you can also try the application there.</p><p><a href="https://huggingface.co/spaces/Ransaka/Code-Assistant">https://huggingface.co/spaces/Ransaka/Code-Assistant</a></p><h3>Conclusion</h3><p>In this tutorial, I aimed to guide the readers through building a code assistant application powered by a large language model. During the testing phase, I noticed some issues. For the reader’s concern, I am adding those known limitations here.</p><ul><li>Chat memory can be appropriately handled in the pipeline steps. In the current implementation, if you ask a follow-up question, this agent won’t be able to recognize the context properly. Therefore, you can try a few possible ways to overcome this challenge. You could try adding memory into the pipeline using custom <a href="https://docs.haystack.deepset.ai/reference/routers-api">routing</a> in the application or a combination of both.</li><li>Even for simple greetings, the current implementation will run whole pipeline steps (including the retriever step) to generate an answer (a simple greeting message). I see that as a resource abuse. A suitable workaround would be <a href="https://docs.haystack.deepset.ai/reference/routers-api">to add a custom route</a> to classify queries and add necessary steps to the pipeline.</li><li>The current pipeline is only suitable for Python GitHub repositories. For repositories in other languages, the reader may want some workaround with data fetching steps.</li></ul><p><em>All images, unless otherwise noted, are by the author.</em></p><h3>Resources</h3><ul><li>All codes related to this tutorial can be accessed via <a href="https://github.com/Ransaka/code_assistant">this GitHub repository</a>.</li><li>The GitHub repository used for data fetching can be seen in <a href="https://github.com/Ransaka/sinlib">this link</a>.</li><li>I found<a href="https://redis.io/learn/howtos/solutions/vector/getting-started-vector"> this Redis helpful resource</a> for someone with minimal knowledge of Redis vector search.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b88beeb42f2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/building-llm-powered-coding-assitant-for-github-rag-with-gemini-and-redis-b88beeb42f2d">Building LLM-Powered Coding Assitant for GitHub: RAG with Gemini and Redis</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Llama 3 for Building AI Agents]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/using-llama-3-for-building-ai-agents-7e74f79d1ccc?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1080/1*EWGo-7t4Kl6l82rB2-ZK9Q.png" width="1080"></a></p><p class="medium-feed-snippet">Comprehensive guide to building AI Agents with Llama 3 function calling capabilities.</p><p class="medium-feed-link"><a href="https://medium.com/data-science/using-llama-3-for-building-ai-agents-7e74f79d1ccc?source=rss-61b4d96de932------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/using-llama-3-for-building-ai-agents-7e74f79d1ccc?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e74f79d1ccc</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 07:26:22 GMT</pubDate>
            <atom:updated>2024-07-31T07:26:22.693Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Demystifying LoRA Fine Tuning]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/geekculture/demystifying-lora-fine-tuning-e43597a0ad8f?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/2600/0*rWgkDHqkebSTOoXe" width="5532"></a></p><p class="medium-feed-snippet">Everything you need to learn about LoRA fine-tuning, from theory, and inner working to implementation.</p><p class="medium-feed-link"><a href="https://medium.com/geekculture/demystifying-lora-fine-tuning-e43597a0ad8f?source=rss-61b4d96de932------2">Continue reading on Geek Culture »</a></p></div>]]></description>
            <link>https://medium.com/geekculture/demystifying-lora-fine-tuning-e43597a0ad8f?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/e43597a0ad8f</guid>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 08:28:34 GMT</pubDate>
            <atom:updated>2024-04-25T08:28:34.534Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Ask questions from the database and save results as files using OpenAI API and LangChain]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ransakaravihara.medium.com/ask-questions-from-the-database-and-save-results-as-files-using-openai-api-and-langchain-4b4e0e35ac88?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1068/1*jpgX5v__7AndaWbYuKugRQ.png" width="1068"></a></p><p class="medium-feed-snippet">Comprehensive guide to building an end-to-end natural language to SQL pipeline using langchain framework.</p><p class="medium-feed-link"><a href="https://ransakaravihara.medium.com/ask-questions-from-the-database-and-save-results-as-files-using-openai-api-and-langchain-4b4e0e35ac88?source=rss-61b4d96de932------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://ransakaravihara.medium.com/ask-questions-from-the-database-and-save-results-as-files-using-openai-api-and-langchain-4b4e0e35ac88?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b4e0e35ac88</guid>
            <category><![CDATA[openai-api]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[vector-embeddings]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Fri, 05 Apr 2024 07:56:27 GMT</pubDate>
            <atom:updated>2024-04-05T07:56:27.995Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[CNN Basics Explained: Beginner’s Guide]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ransakaravihara.medium.com/cnn-basics-explained-beginners-guide-c710d8e53000?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1554/1*VnJB-C_w0ltGK5jW11JBcQ.png" width="1554"></a></p><p class="medium-feed-snippet">A simple introduction to convolution neural network</p><p class="medium-feed-link"><a href="https://ransakaravihara.medium.com/cnn-basics-explained-beginners-guide-c710d8e53000?source=rss-61b4d96de932------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://ransakaravihara.medium.com/cnn-basics-explained-beginners-guide-c710d8e53000?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/c710d8e53000</guid>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 06:52:44 GMT</pubDate>
            <atom:updated>2024-02-13T06:52:44.323Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building YouTube Recommender System with Video Thumbnails and Titles]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/building-youtube-recommender-system-with-video-thumbnails-and-titles-423a2120b4dc?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/2600/0*j6jyeK1nI2p4FrWU" width="5983"></a></p><p class="medium-feed-snippet">Building a deep learning-based recommender system for YouTube thumbnails and titles with Python.</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/building-youtube-recommender-system-with-video-thumbnails-and-titles-423a2120b4dc?source=rss-61b4d96de932------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/building-youtube-recommender-system-with-video-thumbnails-and-titles-423a2120b4dc?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/423a2120b4dc</guid>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 18:01:48 GMT</pubDate>
            <atom:updated>2024-02-08T14:06:22.679Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to Train BERT for Masked Language Modeling Tasks]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/how-to-train-bert-for-masked-language-modeling-tasks-3ccce07c6fdc?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1862/1*4LriARDWTx6M82sABg2TyQ.png" width="1862"></a></p><p class="medium-feed-snippet">Hands-on guide to building language model for MLM tasks from scratch using Python and Transformers library</p><p class="medium-feed-link"><a href="https://medium.com/data-science/how-to-train-bert-for-masked-language-modeling-tasks-3ccce07c6fdc?source=rss-61b4d96de932------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/how-to-train-bert-for-masked-language-modeling-tasks-3ccce07c6fdc?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ccce07c6fdc</guid>
            <category><![CDATA[masked-language-model]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[bert]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 19:05:16 GMT</pubDate>
            <atom:updated>2023-12-12T03:13:21.989Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[What is Quantization in Deep Learning: Recipe to Making Deep Learning Models Faster in Production]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ransakaravihara.medium.com/what-is-quantization-in-deep-learning-recipe-to-making-deep-learning-models-faster-in-production-ca93ba885747?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1920/1*ki9cycnEV-jKjROYH3ySjw.jpeg" width="1920"></a></p><p class="medium-feed-snippet">Comprehensive Guide to Quantization Methods Used in Deep Learning</p><p class="medium-feed-link"><a href="https://ransakaravihara.medium.com/what-is-quantization-in-deep-learning-recipe-to-making-deep-learning-models-faster-in-production-ca93ba885747?source=rss-61b4d96de932------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://ransakaravihara.medium.com/what-is-quantization-in-deep-learning-recipe-to-making-deep-learning-models-faster-in-production-ca93ba885747?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca93ba885747</guid>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Fri, 26 May 2023 08:30:34 GMT</pubDate>
            <atom:updated>2023-05-26T08:30:34.378Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Geospatial Indexing and Scoring: Unlocking the Power of Location-Based Data Analysis]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/data-science/geospatial-indexing-and-scoring-unlocking-the-power-of-location-based-data-analysis-b77a7599b4c?source=rss-61b4d96de932------2"><img src="https://cdn-images-1.medium.com/max/1105/1*3KeHwu9ourA6yBPn8KVITA.jpeg" width="1105"></a></p><p class="medium-feed-snippet">A hands-on guide on geospatial indexing using Python &amp; H3</p><p class="medium-feed-link"><a href="https://medium.com/data-science/geospatial-indexing-and-scoring-unlocking-the-power-of-location-based-data-analysis-b77a7599b4c?source=rss-61b4d96de932------2">Continue reading on TDS Archive »</a></p></div>]]></description>
            <link>https://medium.com/data-science/geospatial-indexing-and-scoring-unlocking-the-power-of-location-based-data-analysis-b77a7599b4c?source=rss-61b4d96de932------2</link>
            <guid isPermaLink="false">https://medium.com/p/b77a7599b4c</guid>
            <category><![CDATA[spatial-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ransaka Ravihara]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 16:01:10 GMT</pubDate>
            <atom:updated>2023-01-25T16:01:10.264Z</atom:updated>
        </item>
    </channel>
</rss>