Skip to content

This Python script retrieves replacement request data from Freshservice and exports it to a CSV file. It also includes an optional AI feature using the Ollama API to rephrase request descriptions for improved clarity. You can customize the data export by specifying the number of days and choose whether to enable AI-powered description rephrasing.

Notifications You must be signed in to change notification settings

asenichHHSD/Freshservice_API_With_AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HHSD Freshservice Python Script


Note

This script was developed specifically for use by HHSD. Please feel free to modify and utilize this code however you see fit.

This Python script gathers replacement request data from Freshservice for the last specified number of days and exports it to a CSV file. Additionally, it can use AI to rephrase the descriptions of the replacement requests, making them more concise and clear. The AI rephrasing feature uses the Ollama API and supports multiple Llama models.

Features


  • Exports replacement data: Fetches data from Freshservice API and exports it to a CSV file in the format output_data_<timestamp>.csv.
  • AI-assisted description rephrasing: Rephrases descriptions using AI (via Ollama), helping to clarify and simplify the content.
  • Customizable export: Allows you to specify the number of days for which you want to export data.
  • CSV format: Data is stored in a CSV file for easy review and analysis.

Requirements


  • Python 3.8 or above
  • Freshservice API key
  • Ollama API for AI rephrasing (if enabled)

Installation


  1. Install Python 3.8 or above.
  2. Install required packages:

pip install requests ollama tqdm

Running the Script


  1. Run FetchReplacementData.py:

    python FetchReplacementData.py

  2. Follow the prompts to enter the Freshservice base URL, API key, and the number of days of data you would like to export. You will also be asked if you'd like to enable AI-powered description rephrasing.

    If AI rephrasing is enabled, the script will revise the original descriptions using the chosen Llama model.

  3. Open the generated CSV file (output_data_<timestamp>.csv) to view the data.

AI Rephrasing Option

  • When prompted, you can choose whether or not to use AI to rephrase the replacement descriptions.
  • You can select between any Ollama supported model for text rephrasing, which will generate clearer and more concise descriptions.

Packaging the Script into an EXE


If you want to distribute this script as an executable, follow these steps:

  1. Install pyinstaller:

    pip install pyinstaller

  2. Package the script:

    pyinstaller.exe -F FetchReplacementData.py

Output


The output file, output_data_<timestamp>.csv, will contain the following fields:

  • Replacement Date
  • Item
  • Model
  • Building
  • Service Request
  • Technician
  • Asset Number
  • Username
  • Full Description
  • AI Description (Optional, generated by the AI if enabled)

Setting up Ollama


alt text

  • Install Ollama on your system by following the system specific directions found here: Ollama Install

  • Download and run your desired model (script is written for llama3.1): Ollama Models

  • Enter model name when asked when running the script

Notes


  • AI rephrasing requires an active Ollama setup, and you will be prompted to select a Llama model during runtime.
  • CSV file output is created in the script directory and is time-stamped for reference.

alt text

About

This Python script retrieves replacement request data from Freshservice and exports it to a CSV file. It also includes an optional AI feature using the Ollama API to rephrase request descriptions for improved clarity. You can customize the data export by specifying the number of days and choose whether to enable AI-powered description rephrasing.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages