{"id":31103701,"url":"https://github.com/oracle-samples/genai-langgraph-graalpy","last_synced_at":"2026-03-04T00:41:06.608Z","repository":{"id":290570354,"uuid":"972558330","full_name":"oracle-samples/genai-langgraph-graalpy","owner":"oracle-samples","description":"This sample code demonstrates how to integrate a Python-based LLM framework within a Helidon MP microservice. It highlights the use of GraalPy for invoking Python scripts and facilitating Python-to-Java communication. ","archived":false,"fork":false,"pushed_at":"2025-04-29T13:17:46.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T14:32:10.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"upl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oracle-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-25T09:19:56.000Z","updated_at":"2025-04-29T13:17:52.000Z","dependencies_parsed_at":"2025-04-29T14:42:31.201Z","dependency_job_id":null,"html_url":"https://github.com/oracle-samples/genai-langgraph-graalpy","commit_stats":null,"previous_names":["oracle-samples/genai-langgraph-graalpy"],"tags_count":0,"template":false,"template_full_name":"oracle/template-repo","purl":"pkg:github/oracle-samples/genai-langgraph-graalpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgenai-langgraph-graalpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgenai-langgraph-graalpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgenai-langgraph-graalpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgenai-langgraph-graalpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oracle-samples","download_url":"https://codeload.github.com/oracle-samples/genai-langgraph-graalpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oracle-samples%2Fgenai-langgraph-graalpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275526374,"owners_count":25480460,"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","status":"online","status_checked_at":"2025-09-17T02:00:09.119Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-09-17T02:50:20.133Z","updated_at":"2025-09-17T02:50:22.909Z","avatar_url":"https://github.com/oracle-samples.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Embedding Python-Based AI Agents into Java Applications\n\n## Introduction\n\nWhile Python is commonly used in AI development, we understand that Java may be the preferred programming language and standard in certain organizations. When developing REST services that incorporate AI with Agent capabilities, finding a suitable Java-based agent framework for integrating Large Language Models (LLMs) or AI Agent solutions can be challenging.\n\nThis sample demonstrates how to use LangGraph and GraalPy to create an agent-based microservice with Helidon MP, enabling seamless integration with Oracle Cloud Infrastructure (OCI) Generative AI services.\n\n## Design\n\n![High Level Design](docs/OCI-GenAI-LangGraph-GraalPy.jpg)\n\n## LangGraph\n\n[LangGraph](https://langchain-ai.github.io/langgraph/) is a powerful framework for building stateful, multi-actor applications utilizing Large Language Models (LLMs). It facilitates the creation of sophisticated agent and multi-agent workflows.\n\n## GraalPy\n\n[GraalPy](https://www.graalvm.org/python/) is a high-performance Python implementation running on the GraalVM platform. By leveraging GraalVM’s advanced capabilities, GraalPy enhances Python's performance. GraalVM is a versatile virtual machine that supports multiple programming languages, providing improved performance, interoperability, and scalability.\n\nKey features of GraalPy:\n- High performance: GraalPy optimizes Python code by leveraging GraalVM's just-in-time (JIT) compiler, resulting in improved execution speed, particularly in performance-sensitive applications.\n- Polyglot interoperability: GraalPy’s polyglot capabilities enable seamless interaction between various languages such as Java, JavaScript, and others, allowing code from different languages to interact without significant overhead.\n- Native interfacing: GraalPy supports interaction with native libraries, allowing Python programs to execute native code. This feature is especially useful for applications requiring system-level optimizations.\n\n## Prerequisite\n\n- OCI CLI installed and configured.\n- Clone this repository.\n- Install a JDK 21. (Note: This is the minimum requirement for Helidon 4.x, see [Helidon v4 documentation](https://helidon.io/docs/v4/mp/guides/config) for details)\nFollow the OCI environment configuration instruction in [Oracle Cloud Infrastructure SDK for Java Configuration](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#:~:text=Oracle%20Cloud%20Infrastructure%20SDK%20for%20Java%20Configuration) to setup the config file.\n\n### Oracle Cloud Infrastructure Services\n\nThis demonstration requires the following Oracle Cloud Infrastructure services:\n\n- [Oracle Cloud Infrastructure Generative AI Service](https://www.oracle.com/au/artificial-intelligence/generative-ai/)\n\n## Configuration and Installation\n\n### Create a Secret in OCI Vault\n\nCreate a vault, master key, and secret for the HCM user to access the HCM API. For detailed instructions, refer to [Creating a Secret in a Vault](https://docs.oracle.com/en-us/iaas/Content/KeyManagement/Tasks/managingsecrets_topic-To_create_a_new_secret.htm). After creating the secret, make sure to copy the vault OCID, compartment OCID, and secret OCID, and include them in the application configuration file in the following configuration step.\n\n### Configuration\n\nModify the _application.yaml_ file in _src/main/resources/application.yaml_ for your enviornment:  \n- Use the OCI Vault environment details created in the previous step and update the `vault-ocid`, `compartment-ocid` and `secret-ocid`.  The OCI `config-profile` is the profile name in `$HOME/.oci/config`, the default is `DEFAULT`.\n- Update the HCM host and HCM username for the HCM API call.\n- Update the following OCI GenAI environment details:\n    - `model_id` : You need to use the chat model for tool call. For example, `cohere.command-r-plus`.\n    - `service_endpoint` : For OCI GenAI interence service endpoint, refer to [Generative AI Service Inference API](https://docs.oracle.com/en-us/iaas/api/#/en/generative-ai-inference/20231130/).\n    - `comparment_id` : Comparmnent OCID of the GenAI Service.\n- The following model parameters are for testing only. Currently, only the following parameters are used in this sample application. Adjust the parameters if required.\n    - `temperature`\n    - `max_tokens`\n    - `seed` \n\n## Build and Package\n\nTo build and package the project, run:\n\n```bash\nmvn clean   #if required, run more than one time to ensure the _target_ folder is deleted.\nmvn package\n```\n\n## Test and Run\n\nRun the Helidon MP server with the following command:\n\n```bash\njava -jar target/langgraph.jar\n```\n\nTo test the service, run this `curl` command:\n\n```bash\ncurl -X POST http://localhost:8080/langgraph/invoke -d'{\"question\":\"Using the Employee API, tell me something about an employee named Casey Brown. Then use the Absences API to find his Absences and see if any approval needed\"}' -H \"Content-Type: application/json\"\n```\n\n## Run in Debug Mode\n\nTo run the application in debug mode, add the following in the Java VM argugment:\n\n```bash\n-Dpolyglot.log.file=./polyglot.log -Dpolyglot.inspect.Path='langgraph' -Dpolyglot.inspect.Suspend='false'\n```\n\nThe above parameters enable the polyglot application to write logs to a file.\nTo run the application, launch _Main.java_ in debug mode from your IDE.\nOnce the application starts, open the Python debugger in Chrome using the following URL: `devtools://devtools/bundled/js_app.html?ws=127.0.0.1:9229/langgraph`.\nIn Chrome, you can set breakpoints and monitor variables as needed.\n\n## Contributing\n\nThis project welcomes contributions from the community. Before submitting a pull request, please review the [contribution guide](CONTRIBUTING.md).\n\n## Distribution\n\nDevelopers choosing to distribute a binary implementation of this project are responsible for obtaining and providing all required licenses and copyright notices for the third-party code used in order to ensure compliance with their respective open-source licenses.\n\n## Security\n\nConsult the [security guide ](SECURITY.md) for the security vulnerability disclosure process.\n\n## Help\n\nVisit Oracle Cloud Customer Connect Community at [Cloud Customer Connect ](https://cloudcustomerconnect.oracle.com/) for additional resources and FAQs.\n\n## License\n\nCopyright (c) 2025, Oracle and / or its affiliates.\nReleased under the Universal Permissive License v1.0 as shown at\nhttps://oss.oracle.com/licenses/upl/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-samples%2Fgenai-langgraph-graalpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foracle-samples%2Fgenai-langgraph-graalpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foracle-samples%2Fgenai-langgraph-graalpy/lists"}