Skip to main content

a lib to parse llm answer to code

Project description

parse_llm_code

parse llm answer to code

use case

Import and use it~

from parse_llm_code.extract_code import extract_code_blocks

test_string = """
\```python
print('first line')
print('second line')
\```

 ```typescript
console.log('first line')
\```
"""

result = extract_code_blocks(test_string)
print(result.code_dict_list)

Output

[
    {
        "language": "python",
        "context": "print('first line')\nprint('second line')",
        "length": 40,
        "lines": 2,
        "include_try": False,
        "include_return": False,
    },
    {
        "language": "typescript",
        "context": "console.log('first line')",
        "length": 25,
        "lines": 1,
        "include_try": False,
        "include_return": False,
    },
]

run test

python3 -m unittest discover -s tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parse_llm_code-0.0.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

parse_llm_code-0.0.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file parse_llm_code-0.0.1.tar.gz.

File metadata

  • Download URL: parse_llm_code-0.0.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.6

File hashes

Hashes for parse_llm_code-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fb881ffc3c74fa46f1abb10f149048c24fc341c971a5b9d03bafb509629e6669
MD5 a79e86c86b902981f8414dcc65d4a525
BLAKE2b-256 08bd5930a1f6a721473159c699c52807a0573dd09cd4cf91e961e7984d1464dc

See more details on using hashes here.

File details

Details for the file parse_llm_code-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for parse_llm_code-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 504aace5f49ddb9a012eeaeaf88dbdb727c1ab5820eaa8c8fa700b4c1bb8ba06
MD5 6c8f233de5e8257c7f6e5809167eaa30
BLAKE2b-256 f0eb9660c8d023cc2f191d9598d06aeb60466c9fa8bf939ab817bc50b2be2f1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page